{"version":3,"names":[],"mappings":"","sources":["search-160212.js"],"sourcesContent":["(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error(\"Cannot find module '\"+o+\"'\");throw f.code=\"MODULE_NOT_FOUND\",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o', {\n id: 'search-form-dropdown'\n }).appendTo('body');\n\n $('#search-form-dropdown').css({\n position: 'absolute',\n top: inputField.offset().top + inputField.outerHeight() + 'px',\n left: inputField.offset().left + 'px',\n width: inputField.outerWidth() + 'px'\n });\n\n for (var i = 0; i < response.length; i++) {\n var newDiv = $('
', {\n class: 'search-form-dropdown-item'\n });\n\n var htmlContent = '';\n if (response[i].track.length > 0) {\n htmlContent = response[i].artist + ' - ' + response[i].track;\n } else {\n htmlContent = response[i].artist;\n }\n htmlContent = htmlContent.replace(/\\\\/g, '');\n\n newDiv.html(htmlContent);\n newDiv.attr('data-url', response[i].url);\n newDiv.appendTo('#search-form-dropdown');\n\n // console.log(response[i]);\n }\n });\n };\n\n $('.search-form-input').keydown(function (event) {\n // console.log(event.which);\n\n if (event.which === 38) {\n // arrow up\n event.preventDefault();\n } else if (event.which === 40) {\n // arrow down\n event.preventDefault();\n }\n });\n\n $('.search-form-input').keyup(function (event) {\n var _this = this;\n\n if (event.which === 13) {\n // let searchString = $(this).val();\n // console.log('search string: ' + searchString);\n\n var _selectedItem = 0;\n\n $('.search-form-dropdown-item').each(function (index) {\n if ($(this).hasClass('item-selected')) {\n // starts from 0, so add 1\n _selectedItem = index + 1;\n }\n });\n\n // if some dropdown item is highlighted, go to exact page\n if (_selectedItem > 0) {\n var url = $('.search-form-dropdown-item:nth-of-type(' + _selectedItem + ')').attr('data-url');\n\n window.location.href = url;\n } else {\n // dropdown item not highlighted, go to google results\n var searchString = $(this).val();\n\n if (searchString.length) {\n var queryString = searchString + ' site:flashlyrics.com';\n var url = 'https://www.google.com/search?q=' + encodeURIComponent(queryString);\n\n window.location.href = url;\n }\n }\n } else if (event.which === 27) {\n $('#search-form-dropdown').remove();\n } else if (event.which === 38 || event.which === 40) {\n var numItems = $('.search-form-dropdown-item').length;\n var selectedItem = 0;\n\n $('.search-form-dropdown-item').each(function (index) {\n if ($(this).hasClass('item-selected')) {\n selectedItem = index + 1;\n }\n });\n\n if (event.which === 38) {\n selectedItem--;\n\n if (selectedItem < 0) {\n selectedItem = numItems;\n }\n } else if (event.which === 40) {\n selectedItem++;\n\n if (selectedItem > numItems) {\n selectedItem = 0;\n }\n }\n\n $('.search-form-dropdown-item').removeClass('item-selected');\n $('.search-form-dropdown-item:nth-of-type(' + selectedItem + ')').addClass('item-selected');\n } else if (event.which === 37) {\n // console.log('left');\n } else if (event.which === 39) {\n // console.log('right');\n } else {\n (function () {\n // console.log('keyup: ' + event.which);\n\n if (globalTimeout !== null) {\n clearTimeout(globalTimeout);\n }\n\n var inputField = $(_this);\n globalTimeout = setTimeout(function () {\n doSearch(inputField);\n }, 300);\n })();\n }\n\n // else if (event.which == 27) { // escape\n // var container = $('#search-form-dropdown');\n\n // container.remove();\n // }\n\n\n // else if (event.which == 37) { // arrow left\n // }\n\n // else if (event.which == 39) { // arrow right\n // }\n\n // else {\n // if(globalTimeout != null) {\n // clearTimeout(globalTimeout);\n // }\n\n // globalTimeout = setTimeout(doSearch, 200);\n // }\n });\n\n $('body').delegate('.search-form-dropdown-item', 'mouseenter', function () {\n $('.search-form-dropdown-item').removeClass('item-selected');\n $(this).addClass('item-selected');\n });\n\n $('body').delegate('.search-form-dropdown-item', 'mouseleave', function () {\n $('.search-form-dropdown-item').removeClass('item-selected');\n });\n\n $('body').delegate('.search-form-dropdown-item', 'click', function () {\n var url = $(this).attr('data-url');\n\n window.location.href = url;\n });\n});\n\n},{}]},{},[1]);\n"],"file":"search-160212.js","sourceRoot":"/source/"}