add solve trigger to calculator

master
Dylan Lloyd 2013-06-28 18:56:27 -04:00
parent 6c89f5e9f9
commit 8c2bbdbed6
2 changed files with 3 additions and 3 deletions

View File

@ -19,7 +19,7 @@ attribution web => [ 'https://www.duckduckgo.com', 'DuckDuckGo' ],
triggers query_nowhitespace => qr< triggers query_nowhitespace => qr<
^ ^
( what is | calculate | math )? !? ( what is | calculate | solve | math )? !?
[\( \) x X * % + / \^ \$ -]* [\( \) x X * % + / \^ \$ -]*
@ -42,7 +42,7 @@ handle query_nowhitespace => sub {
my $results_no_html; my $results_no_html;
my $query = $_; my $query = $_;
$query =~ s/^(?:whatis|calculate|math)//; $query =~ s/^(?:whatis|calculate|solve|math)//;
if($query !~ /[xX]\s*[\*\%\+\-\/\^]/ && $query !~ /^-?[\d]{2,3}\.\d+,\s?-?[\d]{2,3}\.\d+$/) { if($query !~ /[xX]\s*[\*\%\+\-\/\^]/ && $query !~ /^-?[\d]{2,3}\.\d+,\s?-?[\d]{2,3}\.\d+$/) {
my $tmp_result = ''; my $tmp_result = '';

View File

@ -15,7 +15,7 @@ ddg_goodie_test(
heading => 'Calculator', heading => 'Calculator',
html => qq(<div>2 - 2 = <a href="javascript:;" onClick="document.x.q.value='0';document.x.q.focus();">0</a></div>) html => qq(<div>2 - 2 = <a href="javascript:;" onClick="document.x.q.value='0';document.x.q.focus();">0</a></div>)
), ),
'2+2' => test_zci( 'solve 2+2' => test_zci(
"2 + 2 = 4", "2 + 2 = 4",
heading => 'Calculator', heading => 'Calculator',
html => qq(<div>2 + 2 = <a href="javascript:;" onClick="document.x.q.value='4';document.x.q.focus();">4</a></div>) html => qq(<div>2 + 2 = <a href="javascript:;" onClick="document.x.q.value='4';document.x.q.focus();">4</a></div>)