Commit 255572b0 authored by jan.koester's avatar jan.koester
Browse files

fixed search method

parent e35f1e5a
Loading
Loading
Loading
Loading
+6 −4
Changes for src/blogi.cpp: 6 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -577,19 +577,21 @@ void blogi::Blogi::searchPage(libhttppp::HttpRequest& curreq, const int tid, con
    search  << "<ul id=\"searchresult\" >"
            << "<li>"
            << "<input type=\"text\" name=\"searchbox\" id=\"searchbox\" value=\"";
    if(!word.empty())
        search  << word.data();
    if(!searchstr.empty())
        search  << searchstr;
    search  << "\"><label for=\"searchbox\" style=\"display:none;\">search</label>"
            << "<button id=\"searchbttn\">Search</button>"
            << "<script>  document.getElementById(\"searchbttn\").addEventListener(\"click\", function (e) { "
            << "window.location.href = '"<<PlgArgs->config->buildurl("search/")<<"'+document.getElementById('searchbox').value.trim(); });</script>"
            << "window.location.href = '"<<PlgArgs->config->buildurl("search/")<<"'+encodeURIComponent(document.getElementById('searchbox').value.trim()); });</script>"
            << "</li>";


    for(SearchRet::Data *cdat=sdat.getfirstData(); cdat; cdat=cdat->nextData()){
        search << "<li>"
               << "<a href=\"" << cdat->anchor << "\" >" << cdat->title << "</a>"
               << "<p> " << cdat->text.data() << "</p>"
               << "<p> ";
        std::copy(cdat->text.begin(),cdat->text.end(),std::back_inserter(search));
        search << "</p>"
               << "</li>";
    }