Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var addNewPrediction = function ( prediction, parent ) {
- /* ( str, Node ) -> new Node
- Add the prediction list item node to parent and return it
- */
- var listItem = document.createElement( 'li' );
- listItem.className = 'prediction-item';
- var optionCont = document.createElement( 'span' );
- listItem.appendChild( optionCont );
- optionCont.className = 'prediction-text';
- var prediction = document.createTextNode( prediction );
- optionCont.appendChild( prediction );
- return listItem;
- }; // End addNewPrediction()
- function strInArray(str, testArray) {
- for (var wordi = 0; wordi < testArray.length; wordi++) {
- var word = testArray[ wordi ];
- if ( word.match( str ) ) { // && outputText.length < 5) { // Why restrict length?
- // Replace matching letters with bold letters (not sure how to do
- // this elegantly, i.e. without just adding to the string)
- var bold = document.create
- var prediction = word.replace( str, '<strong>' + str + '</strong>' );
- outputText.push('<li class="prediction-item"><span class="prediction-text">' + prediction + '</span></li>');
- }
- }
- } // end for testArray
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement