1/** 2 * ê²ì Placeholder ëì ë³ê²½ ì¤í¬ë¦½í¸ 3 * ëë¤/ê³ ì íì ì§ì 4 */ 5 6(function() { 7 'use strict'; 8 9 try { 10 const DEFAULT_P = 'Tressy Track Jacket Product. 16'; 11 const DELAY = 500; 12 const SELECTOR = 'a.side[data-side="search"], #tnb a[data-side="search"], #tnb-mobile a.search'; 13 14 let data = { 15 items: [], 16 type: 'DEFAULT', 17 loading: false 18 }; 19 20 function getCountry() { 21 return (config.language && typeof config.language === 'string') 22 ? config.language.toUpperCase() 23 : 'KR'; 24 } 25 26 function getInput() { 27 return $('#search-placeholder-input'); 28 } 29 30 function setText(text) { 31 const $input = getInput(); 32 if ($input.length) { 33 $input.attr('placeholder', text); 34 } 35 } 36 37 function isOpen() { 38 const $input = getInput(); 39 const $sidebar = $('#sidebar-aside'); 40 return $sidebar.hasClass('on') && 41 $sidebar.hasClass('search') && 42 $input.is(':visible'); 43 } 44 45 function loadData() { 46 if (data.loading || !getInput().length) { 47 return; 48 } 49 50 data.loading = true; 51 52 $.ajax({ 53 type: 'GET', 54 url: config.api + 'setting/search-placeholder/get', 55 data: { 56 country_code: getCountry(), 57 sidebar_open: '1' 58 }, 59 dataType: 'json', 60 success: function(response) { 61 data.loading = false; 62 63 if (response.code === 200 && response.data && response.data.placeholders) { 64 data.items = response.data.placeholders; 65 data.type = response.data.initial_display_type || 'DEFAULT'; 66 67 const idx = response.data.initial_index !== undefined 68 ? response.data.initial_index 69 : 0; 70 setText(data.items[idx] || DEFAULT_P); 71 } else { 72 setText(DEFAULT_P); 73 } 74 }, 75 error: function() { 76 data.loading = false; 77 setText(DEFAULT_P); 78 } 79 }); 80 } 81 82 function onClick() { 83 if (data.loading || !getInput().length) { 84 return; 85 } 86 87 // ì´ë¯¸ ë¡ëë ë°ì´í°ê° ìì¼ë©´ ì¦ì íì 88 if (data.items.length > 0) { 89 if (data.type === 'RANDOM_ON_LOAD') { 90 // ëë¤: ìì ëë¤ íì í API í¸ì¶ 91 const idx = Math.floor(Math.random() * data.items.length); 92 setText(data.items[idx]); 93 loadData(); 94 } else { 95 // DEFAULT: 첫 ë²ì§¸ placeholder íì 96 setText(data.items[0]); 97 } 98 return; 99 } 100 101 // 첫 ë²ì§¸ í¸ì¶ ì 102 requestAnimationFrame(function() { 103 if (!isOpen()) { 104 return; 105 } 106 setText(DEFAULT_P); 107 loadData(); 108 }); 109 } 110 111 function init() { 112 if (typeof $ === 'undefined' || !$.fn.jquery) { 113 return; 114 } 115 116 setTimeout(function() { 117 if (getInput().length) { 118 $(document).on('click.placeholder', SELECTOR, onClick); 119 } 120 }, DELAY); 121 } 122 123 // ì´ê¸°í 124 if (typeof $ !== 'undefined' && $.fn.jquery) { 125 $(document).ready(init); 126 } else if (document.readyState === 'loading') { 127 document.addEventListener('DOMContentLoaded', init); 128 } else { 129 init(); 130 } 131 132 } catch (e) { 133 // ì¤í¬ë¦½í¸ ì¤ë¥ 무ì 134 } 135 136})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.