Search me



  • I'm doing an online training course and for the hell of it I decided to look at the source code of one of the pages, and I saw this among the code. I have no idea what they are trying to achieve .. but it sure looks like a WTF to me (apologies for the syntax highlighter I used):

    <html><body style='color:#000000; background:#ffffff; '>
    function fixsearchstring(){
    	last_search_data=" " + last_search_string.toLowerCase() + " "
    	last_search_data=fur(last_search_data,"  "," ")
    	last_search_data=fur(last_search_data,"ing "," ")
    	last_search_data=fur(last_search_data,"ed "," ")
    	last_search_data=fur(last_search_data,"es "," ")
    	last_search_data=fur(last_search_data,"s "," ")
    	last_search_data=fur(last_search_data,"e "," ")
    	last_search_data=fur(last_search_data,"  "," ")
    	searchtype="and"
    	if (last_search_data.indexOf(' or ')>0){searchtype="or"}
    	last_search_data=fur(last_search_data," and "," ")
    	last_search_data=fur(last_search_data," or "," ")
    	last_search_data=fur(last_search_data,"  "," ")
    	last_search_data=fur(last_search_data, "[", " ")
    	last_search_data=fur(last_search_data, "]", " ")
    	last_search_data=fur(last_search_data, "!", " ")
    	last_search_data=fur(last_search_data, "%", " ")
    	last_search_data=fur(last_search_data, "&", " ")
    	last_search_data=fur(last_search_data, "_", " ")
    	last_search_data=fur(last_search_data, "", " ")
    	last_search_data=fur(last_search_data, "=", " ")
    	last_search_data=fur(last_search_data, "?", " ")
    	last_search_data=fur(last_search_data, "/", " ")
    	last_search_data=fur(last_search_data, "\n", " ")
    	last_search_data=fur(last_search_data, ".", " ")
    	last_search_data=fur(last_search_data, ",", " ")
    	last_search_data=fur(last_search_data, ";", " ")
    	last_search_data=fur(last_search_data, ":", " ")
    	last_search_data=fur(last_search_data, "", " ")
    	last_search_data=fur(last_search_data, "#", " ")
    	last_search_data=fur(last_search_data, "$", " ")
    	last_search_data=fur(last_search_data, "-", " ")
    	last_search_data=fur(last_search_data, "", " ")
    	last_search_data=fur(last_search_data, "*", " ")
    	last_search_data=fur(last_search_data, "", "")
    	smallwordsfound=""
    	last_search_data=fur2(last_search_data, " we ", " ")
    	last_search_data=fur2(last_search_data, " use ", " ")
    	last_search_data=fur2(last_search_data, " like ", " ")
    	last_search_data=fur2(last_search_data, " any ", " ")
    	last_search_data=fur2(last_search_data, " you ", " ")
    	last_search_data=fur2(last_search_data, " can ", " ")
    	last_search_data=fur2(last_search_data, " any ", " ")
    	last_search_data=fur2(last_search_data, " one ", " ")
    	last_search_data=fur2(last_search_data, " no ", " ")
    	last_search_data=fur2(last_search_data, " our ", " ")
    	last_search_data=fur2(last_search_data, " us ", " ")
    	last_search_data=fur2(last_search_data, " one ", " ")
    	last_search_data=fur2(last_search_data, " he ", " ")
    	last_search_data=fur2(last_search_data, " than ", " ")
    	last_search_data=fur2(last_search_data, " i ", " ")
    	last_search_data=fur2(last_search_data, " who ", " ")
    	last_search_data=fur2(last_search_data, " also ", " ")
    	last_search_data=fur2(last_search_data, " often ", " ")
    	last_search_data=fur2(last_search_data, " she ", " ")
    	last_search_data=fur2(last_search_data, " the ", " ")
    	last_search_data=fur2(last_search_data, " and ", " ")
    	last_search_data=fur2(last_search_data, " them ", " ")
    	last_search_data=fur2(last_search_data, " with ", " ")
    	last_search_data=fur2(last_search_data, " an ", " ")
    	last_search_data=fur2(last_search_data, " or ", " ")
    	last_search_data=fur2(last_search_data, " there ", " ")
    	last_search_data=fur2(last_search_data, " some ", " ")
    	last_search_data=fur2(last_search_data, " from ", " ")
    	last_search_data=fur2(last_search_data, " that ", " ")
    	last_search_data=fur2(last_search_data, " like ", " ")
    	last_search_data=fur2(last_search_data, " your ", " ")
    	last_search_data=fur2(last_search_data, " many ", " ")
    	last_search_data=fur2(last_search_data, " only ", " ")
    	last_search_data=fur2(last_search_data, " on ", " ")
    	last_search_data=fur2(last_search_data, " some ", " ")
    	last_search_data=fur2(last_search_data, " only ", " ")
    	last_search_data=fur2(last_search_data, " may ", " ")
    	last_search_data=fur2(last_search_data, " by ", " ")
    	last_search_data=fur2(last_search_data, " how ", " ")
    	last_search_data=fur2(last_search_data, " if ", " ")
    	last_search_data=fur2(last_search_data, " all ", " ")
    	last_search_data=fur2(last_search_data, " with ", " ")
    	last_search_data=fur2(last_search_data, " all ", " ")
    	last_search_data=fur2(last_search_data, " on ", " ")
    	last_search_data=fur2(last_search_data, " these ", " ")
    	last_search_data=fur2(last_search_data, " does ", " ")
    	last_search_data=fur2(last_search_data, " will ", " ")
    	last_search_data=fur2(last_search_data, " all ", " ")
    	last_search_data=fur2(last_search_data, " now ", " ")
    	last_search_data=fur2(last_search_data, " here ", " ")
    	last_search_data=fur2(last_search_data, " to ", " ")
    	last_search_data=fur2(last_search_data, " is ", " ")
    	last_search_data=fur2(last_search_data, " as ", " ")
    	last_search_data=fur2(last_search_data, " a ", " ")
    	last_search_data=fur2(last_search_data, " at ", " ")
    	last_search_data=fur2(last_search_data, " are ", " ")
    	last_search_data=fur2(last_search_data, " this ", " ")
    	last_search_data=fur2(last_search_data, " of ", " ")
    	last_search_data=fur2(last_search_data, " what ", " ")
    	last_search_data=fur2(last_search_data, " but ", " ")
    	last_search_data=fur2(last_search_data, " which ", " ")
    	last_search_data=fur2(last_search_data, " why ", " ")
    	last_search_data=fur2(last_search_data, " not ", " ")
    	last_search_data=fur2(last_search_data, " do ", " ")
    	last_search_data=fur2(last_search_data, " so ", " ")
    	last_search_data=fur2(last_search_data, " for ", " ")
    	last_search_data=fur2(last_search_data, " him ", " ")
    	last_search_data=fur2(last_search_data, " his ", " ")
    	last_search_data=fur2(last_search_data, " her ", " ")
    	last_search_data=fur2(last_search_data, " were ", " ")
    	last_search_data=fur2(last_search_data, " in ", " ")
    	last_search_data=fur2(last_search_data, " was ", " ")
    	last_search_data=fur2(last_search_data, " set ", " ")
    	last_search_data=fur2(last_search_data, " be ", " ")
    	last_search_data=fur2(last_search_data, " been ", " ")
    	last_search_data=fur2(last_search_data, " way ", " ")
    	last_search_data=fur2(last_search_data, " it ", " ")
    	last_search_data=fur2(last_search_data, " yet ", " ")
    	last_search_data=fur2(last_search_data, " have ", " ")
    	last_search_data=fur2(last_search_data, " had ", " ")
    	last_search_data=fur2(last_search_data, " has ", " ")
    	last_search_data=fur2(last_search_data, " said ", " ")
    	last_search_data=fur2(last_search_data, " its ", " ")
    	last_search_data=fur2(last_search_data, " more ", " ")
    	last_search_data=fur2(last_search_data, " where ", " ")
    }
    
    function fur2(rstring,rwith,rwith2){
    	do{
    		if (rstring.indexOf(rwith)>-1){smallwordsfound=smallwordsfound + "<B>" + rwith + "</B> "}
    		rstring=rstring.replace(rwith, rwith2)
    	}
    	while (rstring.indexOf(rwith, 1) > 0)
    	return rstring
    }
    
    function fur(rstring,rwith,rwith2){
    	do{
    		rstring=rstring.replace(rwith, rwith2)
    	}
    	while (rstring.indexOf(rwith, 1) > 0)
    	return rstring
    }
    


  • Browser error: wtf.js:72187839483 TL;DR



  • Stop words done badly.



  • Presumably it is supposed to strip out punctuation and short uninteresting words (like conjunctions, personal pronouns etc.) to turn some string into a whitespace separated lists of keywords for a search indexer to deal with.

    Bloody clunky way of doing it if you ask me, but certainly a reasonable thing to want to do.



  •  TRWTF is calling functions 'fur' and 'fur2'



  • Fix Unusual Rendering method. fur()



  • @Helix said:

     TRWTF is calling functions 'fur' and 'fur2'

     

    Damn furries are everywhere.

     



  • Maybe they were naming their functions alphabetically.

    You know, the first function is called fun, then comes fuo, fup, fuq, fur, fus...


  • Winner of the 2016 Presidential Election

    @spamcourt said:

    You know, the first function is called fun, then comes fuo, fup, fuq, fur...

    Then comes fap, fap, fap, fap, fap, fap...


  • Discourse touched me in a no-no place

    The first part of that code looks like a WTFy attempt at a stemmer. A very poor one at that.



  • Next, on How to Roll Your Own WTFery ...



  • @Lorne Kates said:

    @Helix said:

     TRWTF is calling functions 'fur' and 'fur2'

     

    Damn furries are everywhere.

     

     

     Leave Blakeyrat alone.  It's not his fault he's a pangolin trapped in a mildly incompetent programmer's body.

     



  • @joe.edwards said:

    Then comes fap, fap, fap, fap, fap, fap...

    Let's hope the furry function doesn't call the fap function...


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.