1var _GLOGALS_UNISUGGEST_REMOVE_HISTORY_KEYWORDS = []; 2 3function makeCategoryItem(catItem) { 4 cat_ids = catItem.direct_category_id.split('|'); 5 cat_id = cat_ids[1]; // 第2é層 6 cat_names = catItem.direct_category_name.split('|'); 7 cat_name = cat_names[1]; // 第2é層 8 $row = $('<div style="display:table-row;"></div>'); 9 if (cat_names[0] == cat_name) { 10 cat_names = cat_names[0] + " ï¼ <span style='color:red'>" + cat_name + "</span> ã«ãã´ãª"; 11 } else { 12 cat_names = "<span style='color:red'>" + cat_name + "</span> ã«ãã´ãª"; 13 } 14 $cell_kw = $('<div class="uni-category">' + cat_names + '</div>'); 15 $row.append($cell_kw); 16 cat_names = $row.prop('outerHTML'); 17 return { label: cat_names, value: "", type: "cat", kw: "", category_id: cat_id } 18} 19 20function makeKeywordItem(kwItem, isHistory = false) { 21 if (kwItem.history_flag || isHistory) { 22 $row = $('<div style="display:table-row;"></div>'); 23 text = '<span class="history-suggest" kw="' + kwItem.word + '">' + kwItem.word + '</span>'; 24 $cell_kw = $('<div style="display:table-cell;">' + text + '</div>'); 25 $row.append($cell_kw); 26 text = $row.prop('outerHTML'); 27 return { label: text, value: kwItem.word, type: "kw", kw: kwItem.word }; 28 } else if (kwItem.mark_category_id) { 29 cat_ids = kwItem.mark_category_id.split('|'); 30 cat_id = cat_ids[1]; // 第2é層 31 cat_names = kwItem.mark_category_name.split('|'); 32 cat_name = cat_names[1]; // 第2é層 33 cat_names = '<div class="uni-kw-cell">' + kwItem.word + ' ã <span style="color:red;">' + cat_name + '</span> ã§æ¤ç´¢</div>'; 34 return { label: cat_names, value: kwItem.word, type: "mr_cat", kw: kwItem.word, category_id: cat_id }; 35 } 36 return { label: kwItem.word, value: kwItem.word, type: "kw", kw: kwItem.word }; 37 38} 39
40function appendRemoveElm() { 41 $('.history-suggest').each(function (index, element) { 42 $(element).parent().after('<i class="fa fa-times remove_btn" kw="' + $(element).attr("kw") + '" onclick="removeHistory(arguments[0],this);return false;"></i>'); 43 }); 44} 45 46function removeHistory(e, element) { 47 e.stopPropagation(); 48 kw = $(element).attr("kw"); 49 url = "//" + unisearch_host + "/history_delete/v1/villagevanguard/" 50 historycallback = function historycallback() { }; 51 $.ajax({ 52 type: 'GET', 53 dataType: 'jsonp', 54 url: url, 55 data: { 56 'q': kw, 57 'wt': 'jsonp', 58 'cbk': "historycallback", 59 'loginid': loginid 60 }, 61 }); 62 _GLOGALS_UNISUGGEST_REMOVE_HISTORY_KEYWORDS.push(kw); 63 var $ul = $(element).closest('ul'); 64 $(element).closest('li').remove(); 65 if ($ul.find('li').length == 0) { 66 $(".head-search-name").autocomplete("close"); 67 $(".filter-search-name").autocomplete("close"); 68 } 69} 70 71function selectItem(row) { 72 item = row["item"]; 73 switch (item.type) { 74 case "kw": 75 location.href = "/products/list?name=" + item.kw; 76 break; 77 case "mr_cat": 78 case "cat": 79 location.href = "/products/list?name=" + item.kw + "&category_id=" + item.category_id; 80 break; 81 82 } 83} 84 85function setCondition(row) { 86 item = row["item"]; 87 switch (item.type) { 88 case "kw": 89 break; 90 case "mr_cat": 91 case "cat": 92 $('.js-category-check[data-category-value="' + item.category_id + '"]').click(); 93 break; 94 95 } 96} 97 98function callApi(req, res) { 99 callback = function callback(data) { 100 let list = []; 101 if (data.response.history) { 102 $.each(data.response.history.docs.item, function (i, item) { 103 var kwItem = makeKeywordItem(item, true); 104 if (!_GLOGALS_UNISUGGEST_REMOVE_HISTORY_KEYWORDS.includes(kwItem.kw)) { 105 list.push(kwItem) 106 } 107 }); 108 } 109 if (data.response.keyword) { 110 $.each(data.response.keyword.docs.item, function (i, item) { 111 list.push(makeKeywordItem(item, false)) 112 }); 113 } 114 if (data.response.keyword && data.response.category) { 115 list.push({ label: "<hr style='margin-top: -1px;margin-bottom: 0;border: 0;border-top: 1px solid #eee;'>" }) 116 } 117 if (data.response.category) { 118 $.each(data.response.category.docs.item, function (i, item) { 119 list.push(makeCategoryItem(item)) 120 }); 121 } 122 res(list); 123 } 124 url = "//" + unisearch_host + "/qsuggest/v1/villagevanguard/"; 125 126 $.ajax({ 127 type: 'GET', 128 dataType: 'jsonp', 129 url: url, 130 data: { 131 'kw': req.term, 132 'rows': '20', 133 'dr_category': '3', 134 'wt': 'jsonp', 135 'mr_category': '3', 136 'cbk': "callback", 137 'history': 'on', 138 'loginid': loginid 139 }, 140 }); 141} 142 143/** 144 * SPãPCãå¤å®ããï¼ç»é¢ã®æ¨ªå¹ ã§å¤å®ï¼ 145 */ 146function isSmartPhone() { 147 if (window.matchMedia && window.matchMedia('(max-device-width: 767px)').matches) { 148 return true; 149 } else { 150 return false; 151 } 152} 153 154$(function () { 155 $(".head-search-name").autocomplete({ 156 minLength: 0, 157 source: function (req, res) { 158 callApi(req, res); 159 }, 160 html: 'html', 161 select: function (event, item) { 162 selectItem(item); 163 }, 164 open: function (event, item) { 165 appendRemoveElm(); 166 $('.ui-autocomplete.ui-front').css('z-index', '100'); 167 $('.ui-autocomplete.ui-front').scrollTop(0); 168 $('.ui-autocomplete.ui-front').css('position', 'absolute'); 169 $('.ui-autocomplete.ui-front').css('top', '34px'); 170 $('.ui-autocomplete.ui-front').css('left', 'auto'); 171 if (isSmartPhone()) { 172 $('.ui-autocomplete.ui-front').css('max-width', $(this).parent().width()); 173 $('.ui-autocomplete.ui-front').css('overflow', 'scroll'); 174 $('.ui-autocomplete.ui-front').css('max-height', '80vh'); 175 } else { 176 $('.ui-autocomplete.ui-front').css('overflow', ''); 177 $('.ui-autocomplete.ui-front').css('max-height', ''); 178 } 179 $(this).parent().append($('.ui-autocomplete.ui-front')); 180 } 181 }).focus(function () { 182 $(this).autocomplete("search", $(this).val()); 183 }); 184 $(".filter-search-name").autocomplete({ 185 minLength: 0, 186 source: function (req, res) { 187 callApi(req, res); 188 }, 189 html: 'html', 190 select: function (event, item) { 191 setCondition(item); 192 }, 193 open: function (event, item) { 194 appendRemoveElm(); 195 $('.ui-autocomplete.ui-front').scrollTop(0); 196 $('.ui-autocomplete.ui-front').css('position', 'absolute'); 197 $('.ui-autocomplete.ui-front').css('top', '34px'); 198 $('.ui-autocomplete.ui-front').css('left', 'auto'); 199 if (isSmartPhone()) { 200 $('.ui-autocomplete.ui-front').css('max-width', $(this).parent().width()); 201 $('.ui-autocomplete.ui-front').css('overflow', 'scroll'); 202 $('.ui-autocomplete.ui-front').css('max-height', '60vh'); 203 } else { 204 $('.ui-autocomplete.ui-front').css('z-index', '10'); 205 $('.ui-autocomplete.ui-front').css('overflow', 'auto'); 206 $('.ui-autocomplete.ui-front').css('max-height', '400px'); 207 } 208 $(this).parent().css('position', 'relative'); 209 $(this).parent().append($('.ui-autocomplete.ui-front')); 210 } 211 }).focus(function () { 212 $(this).autocomplete("search", $(this).val()); 213 });; 214});
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.