{"version":3,"names":[],"mappings":"","sources":["search.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('#search-form-input-wrapper');\n\n $('#search-form-dropdown').css({\n position: 'absolute',\n top: $('#search-form-input-wrapper').offset().top + $('#search-form-input').outerHeight() + 'px',\n left: $('#search-form-input-wrapper').offset().left + 'px',\n width: $('#search-form-input-wrapper').outerWidth() + 'px'\n });\n\n $(response).each(function () {\n var newDiv = $('
', {\n class: 'search-form-dropdown-item'\n });\n if ($(this)[0].track.length > 0) {\n newDiv.html($(this)[0].artist + ' - ' + $(this)[0].track);\n } else {\n newDiv.html($(this)[0].artist);\n }\n newDiv.attr('data-url', $(this)[0].url);\n\n newDiv.appendTo('#search-form-dropdown');\n });\n });\n }\n\n $('#search-form-input').keydown(function (event) {\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 if (event.which == 13) {\n // enter\n var selectedItem = 0;\n\n $('.search-form-dropdown-item').each(function (index) {\n if ($(this).hasClass('item-selected')) {\n selectedItem = index + 1; // starts from 0\n }\n });\n\n if (selectedItem > 0) {\n // some dropdown item is highlighted, go to exact page\n var url = $('.search-form-dropdown-item:nth-of-type(' + selectedItem + ')').attr('data-url');\n\n logClick(url);\n window.location.href = url;\n } else {\n // dropdown item not highlighted, go to google results\n var searchString = $('#search-form-input').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 logClick(url);\n window.location.href = url;\n }\n }\n } else if (event.which == 27) {\n // escape\n var container = $('#search-form-dropdown');\n\n container.remove();\n } else if (event.which == 38) {\n // arrow up\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; // starts from 0\n }\n });\n\n selectedItem--;\n if (selectedItem < 0) {\n selectedItem = numItems;\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 == 40) {\n // arrow down\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; // starts from 0\n }\n });\n\n selectedItem++;\n if (selectedItem > numItems) {\n selectedItem = 0;\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) {// arrow left\n } else if (event.which == 39) {// arrow right\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 logClick(url);\n window.location.href = url;\n });\n\n $('body').mouseup(function (e) {\n var container = $('#search-form-dropdown');\n\n if (!container.is(e.target) // if the target of the click isn't the container...\n && container.has(e.target).length === 0) // ... nor a descendant of the container\n {\n container.remove();\n }\n });\n\n function logClick(linkUrl) {}\n //var linkClass = 'search-link';\n //var pageUrl = window.location.href;\n //\n //var postUrl = 'https://www.rxlyrics.com/controller/linktracker.php';\n //var postData = {\n // linkUrl : linkUrl,\n // linkClass : linkClass,\n // pageUrl : pageUrl,\n //};\n //\n //$.post(postUrl, postData, function(response) {\n //});\n\n\n //$('#search-form-input').attr('placeholder', 'Search lyrics...');\n\n function doSearch2() {\n var postUrl = 'https://www.flashlyrics.com/controller/search2.php';\n var query = $('#search2-form-input').val();\n\n if (query.length < 2) {\n $('#search2-form-dropdown').remove();\n\n return;\n }\n\n var postData = {\n search: $('#search2-form-input').val()\n };\n\n $.post(postUrl, postData, function (response) {\n $('#search2-form-dropdown').remove();\n\n $('
', {\n id: 'search2-form-dropdown'\n }).appendTo('#search2-form-input-wrapper');\n\n $('#search2-form-dropdown').css({\n position: 'absolute',\n top: $('#search2-form-input').offset().top + $('#search2-form-input').outerHeight() + 'px',\n left: $('#search2-form-input').offset().left + 'px',\n width: $('#search2-form-input').outerWidth() + 'px'\n });\n\n $(response).each(function () {\n var newDiv = $('
', {\n class: 'search2-form-dropdown-item'\n });\n if ($(this)[0].track.length > 0) {\n newDiv.html($(this)[0].artist + ' - ' + $(this)[0].track);\n } else {\n newDiv.html($(this)[0].artist);\n }\n newDiv.attr('data-url', $(this)[0].url);\n\n newDiv.appendTo('#search2-form-dropdown');\n });\n });\n }\n\n $('#search2-form-input').keydown(function (event) {\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 $('#search2-form-input').keyup(function (event) {\n if (event.which == 13) {\n // enter\n var selectedItem = 0;\n\n $('.search2-form-dropdown-item').each(function (index) {\n if ($(this).hasClass('item-selected')) {\n selectedItem = index + 1; // starts from 0\n }\n });\n\n if (selectedItem > 0) {\n // some dropdown item is highlighted, go to exact page\n var url = $('.search2-form-dropdown-item:nth-of-type(' + selectedItem + ')').attr('data-url');\n\n logClick(url);\n window.location.href = url;\n } else {\n // dropdown item not highlighted, go to google results\n var searchString = $('#search2-form-input').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 logClick(url);\n window.location.href = url;\n }\n }\n } else if (event.which == 27) {\n // escape\n var container = $('#search2-form-dropdown');\n\n container.remove();\n } else if (event.which == 38) {\n // arrow up\n var numItems = $('.search2-form-dropdown-item').length;\n var selectedItem = 0;\n\n $('.search2-form-dropdown-item').each(function (index) {\n if ($(this).hasClass('item-selected')) {\n selectedItem = index + 1; // starts from 0\n }\n });\n\n selectedItem--;\n if (selectedItem < 0) {\n selectedItem = numItems;\n }\n\n $('.search2-form-dropdown-item').removeClass('item-selected');\n $('.search2-form-dropdown-item:nth-of-type(' + selectedItem + ')').addClass('item-selected');\n } else if (event.which == 40) {\n // arrow down\n var numItems = $('.search2-form-dropdown-item').length;\n var selectedItem = 0;\n\n $('.search2-form-dropdown-item').each(function (index) {\n if ($(this).hasClass('item-selected')) {\n selectedItem = index + 1; // starts from 0\n }\n });\n\n selectedItem++;\n if (selectedItem > numItems) {\n selectedItem = 0;\n }\n\n $('.search2-form-dropdown-item').removeClass('item-selected');\n $('.search2-form-dropdown-item:nth-of-type(' + selectedItem + ')').addClass('item-selected');\n } else if (event.which == 37) {// arrow left\n } else if (event.which == 39) {// arrow right\n } else {\n if (globalTimeout != null) {\n clearTimeout(globalTimeout);\n }\n\n globalTimeout = setTimeout(doSearch2, 200);\n }\n });\n\n $('body').delegate('.search2-form-dropdown-item', 'mouseenter', function () {\n $('.search2-form-dropdown-item').removeClass('item-selected');\n $(this).addClass('item-selected');\n });\n\n $('body').delegate('.search2-form-dropdown-item', 'mouseleave', function () {\n $('.search2-form-dropdown-item').removeClass('item-selected');\n });\n\n $('body').delegate('.search2-form-dropdown-item', 'click', function () {\n var url = $(this).attr('data-url');\n\n logClick(url);\n window.location.href = url;\n });\n\n $('body').mouseup(function (e) {\n var container = $('#search2-form-dropdown');\n\n if (!container.is(e.target) // if the target of the click isn't the container...\n && container.has(e.target).length === 0) // ... nor a descendant of the container\n {\n container.remove();\n }\n });\n});\n\n},{}]},{},[1]);\n"],"file":"search.js","sourceRoot":"/source/"}