{"id":1309,"date":"2021-03-25T07:28:32","date_gmt":"2021-03-25T07:28:32","guid":{"rendered":"http:\/\/127.0.0.1\/?page_id=1309"},"modified":"2021-03-25T10:35:42","modified_gmt":"2021-03-25T10:35:42","slug":"search-ru","status":"publish","type":"page","link":"https:\/\/tahometer.com\/ru\/help-center\/search-ru\/","title":{"rendered":"\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u043e\u0438\u0441\u043a\u0430"},"content":{"rendered":"<div data-elementor-type=\"wp-page\" data-elementor-id=\"1309\" class=\"elementor elementor-1309\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-098d610 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"098d610\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-6f93994\" data-id=\"6f93994\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-inner-section elementor-element elementor-element-06a5fec elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"06a5fec\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-50 elementor-inner-column elementor-element elementor-element-2825a04 help-center-breadcrumb\" data-id=\"2825a04\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-aa2e010 elementor-widget elementor-widget-wp-widget-taho_breadcrumb_widget\" data-id=\"aa2e010\" data-element_type=\"widget\" data-widget_type=\"wp-widget-taho_breadcrumb_widget.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t <div class=\"taho-breadcrumb\"><a href=\"\/ru\/help-center\/\" rel=\"nofollow\">\u0426\u0435\u043d\u0442\u0440 \u041f\u043e\u043c\u043e\u0449\u0438<\/a><\/div>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t<div class=\"elementor-column elementor-col-50 elementor-inner-column elementor-element elementor-element-25f3714\" data-id=\"25f3714\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-9131283 detailed-help-search elementor-widget elementor-widget-wp-widget-spg_widget_search\" data-id=\"9131283\" data-element_type=\"widget\" data-widget_type=\"wp-widget-spg_widget_search.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t        <script>\n            function getCurrentLanguage() {\n                let className = $('body').attr(\"class\")\n                    .split(\/\\s+\/)\n                    .filter(c => c.startsWith('translatepress-'))\n                    [0];\n                return \/translatepress-(.+)_(.+)\/.exec(className)[1];\n            }\n\n            var redirect_to_help = function (url, index) {\n                window.location.href = `${url}?article=${index}`;\n            }\n\n            let allSuggestions;\n            let data = {\n                'lang': getCurrentLanguage(),\n            };\n            jQuery.get(\"\/index.php\/wp-json\/help-center\/v1\/search\/\", data, function (response) {\n                allSuggestions = response;\n            }, 'json');\n\n            jQuery(document).ready(function ($) {\n                let suggestions = $(\".search-suggestions\")\n                $(\".custom-search-input\").bind(\" input paste\", function () {\n                    let searchQuery = $(\".custom-search-input\").val();\n                    if (searchQuery.trim().length >= 3) {\n                        let html = getSuggestionHTML(allSuggestions, searchQuery)\n                        suggestions.css(\"display\", \"flex\");\n                        suggestions.html(html);\n                        suggestions.css(\"display\", \"flex\");\n                    } else {\n                        suggestions.css(\"display\", \"none\");\n                    }\n                });\n\n                $(window).click(function () {\n                    suggestions.css(\"display\", \"none\");\n                });\n\n                $('.searchform').click(function (event) {\n                    event.stopPropagation();\n                });\n\n                function getSuggestionHTML(allSuggestions, searchText) {\n                    \/\/ Emit click if were pressed 'Enter' on focused suggestion\n                    handleEnter = function (e) {\n                        var key = e.key || e.keyCode;\n                        if (key == 'Enter' || key == '13') {\n                            document.activeElement.click();\n                        }\n                    }\n\n                    allSuggestions = allSuggestions\n                        .filter((suggestion) => suggestion.description.toLowerCase().includes(searchText.toLowerCase()))\n                        .sort((a, b) =>\n                            a.description.toLowerCase().indexOf(searchText.toLowerCase())\n                            - b.description.toLowerCase().indexOf(searchText.toLowerCase()))\n                        .slice(0, 6);\n\n                    let result = \"\";\n                    for (const suggestion of allSuggestions) {\n                        const description = suggestion.description.replace(new RegExp(`(${searchText})`, \"gi\"), \"<span class='searchable-word'>$1<\/span>\");\n                        result += `<div class=\"search-row\" onclick=\"redirect_to_help('${suggestion.url}',${suggestion.index})\"\n                                        onkeypress=\"handleEnter(event)\"\n                                        title=\"${suggestion.description}\" tabindex=\"0\">\n                                        <div class=\"search-suggestion-element\">\n                                            <p class=\"search-page-topic\">${description}<\/p>\n                                            <span class=\"search-page-name\">&nbsp;- ${suggestion.articleName}<\/span>\n                                        <\/div>\n                                   <\/div>`;\n                    }\n                    return result;\n\n                }\n\n                $(\".searchform\").submit(function() {\n                    let search_query = $('.custom-search-input').val();\n                    if (\/\\\/ru\\\/help-center\\\/\/.exec(window.location.href)) {\n                        window.location.href = `\/ru\/help-center\/search-ru?query=${search_query}`;\n                    } else {\n                        window.location.href = `\/help-center\/search?query=${search_query}`;\n                    }\n                    return false; \/\/ To prevent form from redirect or refresh the page\n                });\n            })\n        <\/script>\n        <form class=\"searchform\"\n              method=\"get\"\n              style=\"padding: 10px;\" action=\"\">\n            <div class=\"input-group input-group-md mr-0\">\n                <input name=\"search-query\"\n                       type=\"text\"\n                       value=\"\"\n                       class=\"form-control custom-search-input\" placeholder=\"Search\"\n                       autocomplete=\"off\"\n                       aria-label=\"Search\">\n            <\/div>\n            <div class=\"search-suggestions\">\n            <\/div>\n        <input type=\"hidden\" name=\"trp-form-language\" value=\"ru\"\/><\/form>\n        \u200b\n        \t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-3e4b090 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"3e4b090\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-6e301e4\" data-id=\"6e301e4\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-9e5bbb5 elementor-widget elementor-widget-wp-widget-taho_widget_detailed_search\" data-id=\"9e5bbb5\" data-element_type=\"widget\" data-widget_type=\"wp-widget-taho_widget_detailed_search.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<div class=\"detailed-search-header\">\n                    <h1>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u043e\u0438\u0441\u043a\u0430<\/h1>\n                    <p><span class=\"detailed-search-results-count\">0<\/span> \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0434\u043b\u044f \"<span class=\"detailed-search-query\"><\/span>\"<\/p>\n              <\/div>\n              <h3 class=\"search-results-subheading\">\u0411\u0430\u0437\u0430 \u0437\u043d\u0430\u043d\u0438\u0439<\/h3>\n              <div class=\"detailed-search-results\"><\/div>        <script>\n        jQuery(document).ready(function ($) {\n            function getCurrentLanguage() {\n                let className = $('body').attr(\"class\")\n                    .split(\/\\s+\/)\n                    .filter(c => c.startsWith('translatepress-'))\n                    [0];\n                return \/translatepress-(.+)_(.+)\/.exec(className)[1];\n            }\n\n            let searchResults = \"\";\n            const searchQuery = getUrlParam('query');\n\n            \/\/ Retrieve search data\n            let currentLanguage = getCurrentLanguage();\n            let data = {\n                'lang': currentLanguage,\n                'query': searchQuery\n            };\n            jQuery.get(\"\/wp-json\/help-center\/v1\/search\/detailed\", data, function (response) {\n                searchResults = response;\n\n                let searchResultsContainer = $(\".detailed-search-results\")\n                let html = getSearchResultsHTML(searchResults)\n                searchResultsContainer.html(html);\n                $(\".detailed-search-results-count\").text(searchResults.length);\n                $(\".detailed-search-query\").text(decodeURIComponent(searchQuery));\n            }, 'json');\n\n            function getSearchResultsHTML(searchResults) {\n                let result = \"\";\n                for (const searchItem of searchResults) {\n                    const url_to_question = searchItem.url + \"?article=\" + searchItem.index;\n                    let answer = searchItem.answer;\n                    \/\/ If has coincidence in answer\n                    if (searchItem.answerCoincidence.length > 0) {\n                        \/\/ Surround coincidences with <span> tag\n                        const coincidencesRegexString = searchItem.answerCoincidence.reduce((a, b) => a + '|' + b);\n                        answer = answer.replace(new RegExp(`(${coincidencesRegexString})`, \"gi\"), \"<span class='searchable-word'>$1<\/span>\");\n\n                        \/\/ leave only sentence with coincidence of searchable string\n                        const sentences = answer.replace(\/(\\.+|\\:|\\!|\\?)(\\\"*|\\'*|\\)*|}*|]*)(\\s|\\n|\\r|\\r\\n)\/gm, \"$1$2|\").split(\"|\")\n                        answer = sentences.filter((value) => value.search(new RegExp(`(${coincidencesRegexString})`, \"gi\")) !== -1)[0];\n                    } else {\n                        \/\/    If has coincidence in question only - display the first sentence of answer\n                        const sentences = answer.replace(\/(\\.+|\\:|\\!|\\?)(\\\"*|\\'*|\\)*|}*|]*)(\\s|\\n|\\r|\\r\\n)\/gm, \"$1$2|\").split(\"|\")\n                        answer = sentences[0];\n                    }\n\n                    result += `<div class=\"detailed-search-item\">\n                                <h3><a class=\"title\" href=\"${url_to_question}\">${searchItem.question}<\/a><\/h3>\n                                <span class=\"breadcrumbs\">\n                                    <a href=\"${currentLanguage === 'en' ? '' : '\/' + currentLanguage}\/help-center\/\">Help Center<\/a> >\n                                    <a href=\"${url_to_question}\">${searchItem.articleName}<\/a>\n                                <\/span>\n                                <p class=\"description\">${answer}<\/p>\n                           <\/div>`;\n                }\n                return result;\n            }\n\n            \/\/ Get parameter of page url\n            function getUrlParam(parameter) {\n                let urlparameter = '';\n                if(window.location.href.indexOf(parameter) > -1){\n                    var vars = {};\n                    window.location.href.replace(\/[?&]+([^=&]+)=([^&]*)\/gi, function(m,key,value) {\n                        vars[key] = value;\n                    });\n                    urlparameter = vars[parameter];\n                }\n                return urlparameter;\n            }\n\n        })\n        <\/script>\n        \t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t<div class=\"clearfix\"><\/div>","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"parent":593,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"elementor_header_footer","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"class_list":["post-1309","page","type-page","status-publish","hentry"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/tahometer.com\/ru\/wp-json\/wp\/v2\/pages\/1309"}],"collection":[{"href":"https:\/\/tahometer.com\/ru\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/tahometer.com\/ru\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/tahometer.com\/ru\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tahometer.com\/ru\/wp-json\/wp\/v2\/comments?post=1309"}],"version-history":[{"count":4,"href":"https:\/\/tahometer.com\/ru\/wp-json\/wp\/v2\/pages\/1309\/revisions"}],"predecessor-version":[{"id":1319,"href":"https:\/\/tahometer.com\/ru\/wp-json\/wp\/v2\/pages\/1309\/revisions\/1319"}],"up":[{"embeddable":true,"href":"https:\/\/tahometer.com\/ru\/wp-json\/wp\/v2\/pages\/593"}],"wp:attachment":[{"href":"https:\/\/tahometer.com\/ru\/wp-json\/wp\/v2\/media?parent=1309"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}