librex icon indicating copy to clipboard operation
librex copied to clipboard

added calculator to special searches

Open bitebait opened this issue 1 year ago • 3 comments

A calculator function has been added to the searches, where you can perform basic arithmetic operations directly in the search bar.

Preview: image

bitebait avatar Sep 05 '22 04:09 bitebait

$special_result = calculator_results($query, curl_multi_getcontent($special_ch));

whats the purpose of the curl_mutli_getcontent there, the calculator results function takes up only 1 parameter anyway and you don't make any external connections for this so it serves no purpose.

Thanks for the review, my mistake, the parameter has been removed... it really shouldn't be there. Fix: 5cdf100

bitebait avatar Sep 05 '22 16:09 bitebait

if (preg_match('~^[0-9\.()+\-*\/]+$~', $query))

you have this check twice, why?

also could you find a better way for the try catch part, I really don't want to add try catch to the code.

after these two are solved I will merge it, thanks again.

hnhx avatar Sep 06 '22 09:09 hnhx

nice 👍

Extravi avatar Sep 06 '22 13:09 Extravi

I have tested the calculator locally and it doesn't seem to be accurate.

e.g.: 12*24+2000 gave a bad result

hnhx avatar Oct 01 '22 10:10 hnhx