1/** 2 * Company name CTA forms (homepage + industry pages). 3 * Each .js-company-name-form is independent: own input, tooltip, optional placeholder animation. 4 */ 5(function (window) { 6 'use strict'; 7 8 var STORAGE_KEY = 'logogenie_company_name'; 9 var STORAGE_AUTOSUBMIT_KEY = 'logogenie_company_auto_submit'; 10 var STORAGE_PRESERVE_INDUSTRY_KEY = 'logogenie_preserve_industry'; 11 var STORAGE_INDUSTRY_ICON_KEY = 'logogenie_industry_icon_id'; 12 var STORAGE_INDUSTRY_KEYWORDS_KEY = 'logogenie_industry_keywords'; 13 var STORAGE_INDUSTRY_KEYWORD_ID_KEY = 'logogenie_industry_keyword_id'; 14 var STORAGE_INDUSTRY_LEAD_ICON_IDS_KEY = 'logogenie_industry_lead_icon_ids'; 15 16 function persistIndustryKeywords(value) { 17 var keywords = (value || '').toString().trim(); 18 if (!keywords) { 19 return; 20 } 21 try { 22 if (window.sessionStorage) { 23 sessionStorage.setItem(STORAGE_INDUSTRY_KEYWORDS_KEY, keywords); 24 } 25 } catch (e) { 26 // Private browsing or blocked storage â editor falls back to referer/category. 27 } 28 } 29 30 function persistIndustryKeywordId(value) { 31 var id = parseInt(value, 10); 32 try { 33 if (!window.sessionStorage) { 34 return; 35 } 36 if (id > 0) { 37 sessionStorage.setItem(STORAGE_INDUSTRY_KEYWORD_ID_KEY, String(id)); 38 } else { 39 sessionStorage.removeItem(STORAGE_INDUSTRY_KEYWORD_ID_KEY); 40 } 41 } catch (e) { 42 // Private browsing or blocked storage. 43 } 44 } 45 46 function readIndustryKeywordsFromElement($el) { 47 if (!$el || !$el.length) { 48 return ''; 49 } 50 return ($el.attr('data-industry-keywords') || '').toString().trim(); 51 } 52 53 function readIndustryKeywordIdFromElement($el) { 54 if (!$el || !$el.length) { 55 return 0; 56 } 57 return parseInt($el.attr('data-industry-id') || '0', 10) || 0; 58 } 59 60 function persistIndustryLeadIconIds(value) { 61 var raw = (value || '').toString().trim(); 62 var ids = []; 63 if (raw) { 64 var parts = raw.split(','); 65 var seen = {}; 66 for (var i = 0; i < parts.length && ids.length < 20; i++) { 67 var id = parseInt(parts[i], 10); 68 if (!id || seen[id]) { 69 continue; 70 } 71 seen[id] = true; 72 ids.push(id); 73 } 74 } 75 try { 76 if (!window.sessionStorage) { 77 return; 78 } 79 if (ids.length) { 80 sessionStorage.setItem(STORAGE_INDUSTRY_LEAD_ICON_IDS_KEY, ids.join(',')); 81 } else { 82 sessionStorage.removeItem(STORAGE_INDUSTRY_LEAD_ICON_IDS_KEY); 83 } 84 } catch (e) { 85 // Private browsing or blocked storage. 86 } 87 } 88 89 function readIndustryLeadIconIdsFromElement($el) { 90 if (!$el || !$el.length) { 91 return ''; 92 } 93 return ($el.attr('data-industry-icon-ids') || '').toString().trim(); 94 } 95 96 function persistCompanyName(value, preserveIndustry) { 97 try { 98 if (window.sessionStorage) { 99 sessionStorage.setItem(STORAGE_KEY, value); 100 sessionStorage.setItem(STORAGE_AUTOSUBMIT_KEY, '1'); 101 if (preserveIndustry) { 102 sessionStorage.setItem(STORAGE_PRESERVE_INDUSTRY_KEY, '1'); 103 } else { 104 sessionStorage.removeItem(STORAGE_PRESERVE_INDUSTRY_KEY); 105 sessionStorage.removeItem(STORAGE_INDUSTRY_ICON_KEY); 106 sessionStorage.removeItem(STORAGE_INDUSTRY_KEYWORD_ID_KEY); 107 sessionStorage.removeItem(STORAGE_INDUSTRY_LEAD_ICON_IDS_KEY); 108 } 109 } 110 } catch (e) { 111 // Private browsing or blocked storage â fall back to query param below. 112 } 113 } 114 115 function redirectToEditor($, $form) { 116 var target = ($form.attr('action') || '/creation-logo').split('?')[0]; 117 var value = $.trim($form.find('.js-company-name-input').first().val()); 118 119 var preserveIndustry = $form.data('preserveIndustry') === 1 120 || $form.data('preserveIndustry') === '1' 121 || $form.attr('data-preserve-industry') === '1'; 122 if (preserveIndustry) { 123 persistIndustryKeywords(readIndustryKeywordsFromElement($form)); 124 persistIndustryKeywordId(readIndustryKeywordIdFromElement($form)); 125 persistIndustryLeadIconIds(readIndustryLeadIconIdsFromElement($form)); 126 }
127 persistCompanyName(value, preserveIndustry); 128 129 // If sessionStorage is unavailable, keep legacy ?text= behaviour. 130 if (!window.sessionStorage) { 131 window.location.href = target + '?text=' + encodeURIComponent(value); 132 return; 133 } 134 135 window.location.href = target; 136 } 137 138 function initCompanyNameForm($, $form) { 139 var $input = $form.find('.js-company-name-input').first(); 140 var $tooltip = $form.find('.tooltip-error').first(); 141 142 if ($input.length === 0) { 143 return; 144 } 145 146 var animationController = null; 147 if ($form.data('animatePlaceholder') === 1 || $form.data('animatePlaceholder') === '1') { 148 animationController = attachPlaceholderAnimation($, $input, { 149 initialDelay: parseInt($form.data('animateDelay'), 10) || 2500 150 }); 151 } 152 153 $input.on('input', function () { 154 $tooltip.stop(true, true).hide(); 155 }); 156 157 $form.on('submit', function (event) { 158 event.preventDefault(); 159 var value = $.trim($input.val()); 160 161 if (!value) { 162 $tooltip.stop(true, true).fadeIn(200); 163 $input.trigger('focus'); 164 return false; 165 } 166 167 $tooltip.stop(true, true).hide(); 168 if (animationController) { 169 animationController.stop(); 170 } 171 172 redirectToEditor($, $form); 173 return false; 174 }); 175 } 176 177 function attachPlaceholderAnimation($, $input, options) { 178 var sourceText = $input.data('text'); 179 if (!sourceText) { 180 return { stop: function () {} }; 181 } 182 183 var shouldAnimate = true; 184 var timerId = null; 185 var initialDelay = options.initialDelay || 2500; 186 187 function clearTimer() { 188 if (timerId !== null) { 189 clearTimeout(timerId); 190 timerId = null; 191 } 192 } 193 194 function typeForward(index) { 195 if (!shouldAnimate) { 196 return; 197 } 198 199 if (index < sourceText.length) { 200 $input.val(sourceText.substring(0, index + 1)); 201 timerId = setTimeout(function () { 202 typeForward(index + 1); 203 }, 125); 204 return; 205 } 206 207 timerId = setTimeout(removeBackward, 2500); 208 } 209 210 function removeBackward() { 211 if (!shouldAnimate) { 212 return; 213 } 214 215 var currentText = $input.val(); 216 if (currentText.length > 0) { 217 $input.val(currentText.substring(0, currentText.length - 1)); 218 timerId = setTimeout(removeBackward, 50); 219 return; 220 } 221 222 timerId = setTimeout(function () { 223 typeForward(0); 224 }, 2500); 225 } 226 227 function stopAnimation(clearValue) { 228 if (!shouldAnimate) { 229 return; 230 } 231 232 shouldAnimate = false; 233 clearTimer(); 234 if (clearValue) { 235 $input.val(''); 236 } 237 } 238 239 $input.on('keydown.companyNameForm mousedown.companyNameForm', function () { 240 stopAnimation(true); 241 }); 242 243 timerId = setTimeout(function () { 244 typeForward(0); 245 }, initialDelay); 246 247 return { 248 stop: function () { 249 stopAnimation(false); 250 } 251 }; 252 } 253 254 function initAll($, root) { 255 var $root = root ? $(root) : $(document); 256 $root.find('.js-company-name-form').each(function () { 257 initCompanyNameForm($, $(this)); 258 }); 259 260 $root.find('.js-industry-palette-link').each(function () { 261 var $link = $(this); 262 if ($link.data('industryPaletteBound') === 1) { 263 return; 264 } 265 $link.data('industryPaletteBound', 1); 266 $link.on('click', function (event) { 267 event.preventDefault(); 268 var target = ($link.attr('href') || '/creation-logo').split('?')[0]; 269 var iconId = parseInt($link.attr('data-icon-id') || '0', 10); 270 try { 271 if (window.sessionStorage) { 272 sessionStorage.setItem(STORAGE_PRESERVE_INDUSTRY_KEY, '1'); 273 persistIndustryKeywords(readIndustryKeywordsFromElement($link)); 274 persistIndustryKeywordId(readIndustryKeywordIdFromElement($link)); 275 persistIndustryLeadIconIds(readIndustryLeadIconIdsFromElement($link)); 276 if (iconId > 0) { 277 sessionStorage.setItem(STORAGE_INDUSTRY_ICON_KEY, iconId); 278 } else { 279 sessionStorage.removeItem(STORAGE_INDUSTRY_ICON_KEY); 280 } 281 } 282 } catch (e) { 283 // Fall through to navigation without session hints. 284 } 285 if ($link[0] && typeof $link[0].blur === 'function') { 286 $link[0].blur(); 287 } 288 window.location.href = target; 289 }); 290 }); 291 } 292 293 window.LogogenieCompanyNameForm = { 294 storageKey: STORAGE_KEY, 295 storageAutoSubmitKey: STORAGE_AUTOSUBMIT_KEY, 296 storagePreserveIndustryKey: STORAGE_PRESERVE_INDUSTRY_KEY, 297 storageIndustryIconKey: STORAGE_INDUSTRY_ICON_KEY, 298 storageIndustryKeywordsKey: STORAGE_INDUSTRY_KEYWORDS_KEY, 299 storageIndustryKeywordIdKey: STORAGE_INDUSTRY_KEYWORD_ID_KEY, 300 init: function (root) { 301 var jq = window.jQuery; 302 if (!jq) { 303 return; 304 } 305 initAll(jq, root); 306 } 307 }; 308}(window));
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.