Problem: Earlier users were not having any option to customise results count in Susper.
Susper is a Frontend for Peer to Peer Search Engine Yacy built using Angular. So, we implemented ‘results count’ feature and used to have a strict restriction of only 10 results per page. Now, users can customise search results in Susper when instant results are turned off. By default, Susper shows only 10 results per page. If the user requires more results per page he can modify the count of results in Susper. To customise the result count visit http://susper.com/preferences and you will find a range bar to customise the results. Change the value of the range bar to the desired value and save it. (Right now we support only results till maximum size of 100)
How did we implement this feature?
The user is displayed with a range slider, that could slide between 0 and 100. The value of the range slider is stored in a resultscount variable in search settings component using ngModel.
searchsettings.component.ts: Later when user clicks on save button, it triggers onSave() function.The resultscount is stored into localStorage of the browser and an action is triggered to inform all other components about the change in the value of resultscount.
Later new resultscount value is used in other components to request the server for search results with new resultscount.
The complete working of Susper’s result count could be seen in this gif
Source code can be found here: https://github.com/fossasia/susper.com/pull/546 .
- localstorage API: https://developer.mozilla.org/en/docs/Web/API/Window/localStorage