diff --git a/html/search.ejs b/html/search.ejs index 7ebcd9a..195f5d1 100644 --- a/html/search.ejs +++ b/html/search.ejs @@ -511,6 +511,7 @@ Web <% +<% function isMathExpression(query) { return /^[0-9\s\+\-\*\/\.\x]+$/.test(query); } @@ -613,6 +614,18 @@ if (isMathExpression(query)) { const options = { weekday: 'long' }; answer = now.toLocaleDateString(undefined, options); } + +const upsellMessages = [ + "[new] Try searching 'What's 4+4?'", + "[new] Ask 'What's the date today?'", + "[new] Try 'What time is it in New York?'", + "[new] Ask 'What's the current year?'", + "[new] Try searching 'What's 7*8?'" +]; + +const showUpsell = !answer && Math.random() < 0.2; +const randomUpsellMessage = showUpsell ? upsellMessages[Math.floor(Math.random() * upsellMessages.length)] : ''; +%> %> <% if (answer) { %>
@@ -623,8 +636,11 @@ if (isMathExpression(query)) { <%= answer %>
+<% } else if (showUpsell) { %> + + <%= randomUpsellMessage %> + <% } %> - <% const searchStrings = [ "suicide", "self harm", "self-harm", "support", "murder", "how to murder", "kill myself",