KhalisFoundation / sttm-web

STTM website - https://www.sikhitothemax.org
https://www.sikhitothemax.org
Open Software License 3.0
50 stars 34 forks source link

Highlight the words in the results based on query #476

Closed bogas04 closed 6 years ago

bogas04 commented 6 years ago

image

bogas04 commented 6 years ago

This is kinda tricky thing to do.

We can only color if we use spans. And when we use spans, larivaar gets bit complicated. And then we're changing larivaar implementation heavily. I'm bit confused.

And then there's unicode, and other cases like romanized/words.

Also, the logic to find substring as of now is this;

const highlightStartIndex = shabad.gurbani.gurmukhi
  // split all words
  .split(' ')
  // get initials only
  .map(e => e[0])
  // join them in a string
  .join('')
  // get index of the query in this string
  .indexOf(q);

const higlightEndIndex = highlightStartIndex + q.length;

This works for first letter searches, but i've to add logic for other cases.

@ManjotS the color choice has to be changed too coz larivaarAssist uses that color.

(mmgg)

screen shot 2018-06-16 at 2 40 46 pm
bogas04 commented 6 years ago

Okay i've supported unicode as well as all other search types (except translation/ang).

Larivaar would be bit complicated and maybe we can release for it later.

@tarunsingh5 @ManjotS @saintsoldierx please give your feedback. If all looks good i can merge it to dev for testing.

Romanized Full Word Gurmukhi First Letter First Letter (Dark)
screen shot 2018-06-16 at 3 42 34 pm screen shot 2018-06-16 at 3 42 49 pm screen shot 2018-06-16 at 3 43 03 pm screen shot 2018-06-16 at 3 49 21 pm
bogas04 commented 6 years ago

Also @ManjotS, I'm in love with Romanized Search. So accurate.

ManjotS commented 6 years ago

What about bisram

On Sat, Jun 16, 2018, 7:14 AM Divjot Singh notifications@github.com wrote:

Closed #476 https://github.com/KhalisFoundation/sttm-web/issues/476 via 0e2ef5b https://github.com/KhalisFoundation/sttm-web/commit/0e2ef5b981bb0548ce1fb8f9f596388713c445a1 .

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/KhalisFoundation/sttm-web/issues/476#event-1684634024, or mute the thread https://github.com/notifications/unsubscribe-auth/AAnXFYk6uH0ezfFcPbodDsF9jk_FV0Dcks5t9PaZgaJpZM4UO0E1 .

bogas04 commented 6 years ago

@ManjotS bisraam for shabad view, query highlight for search results?

ManjotS commented 6 years ago

Bisram on should apply everywhere @bogas04