fix stuff + add stuff
This commit is contained in:
parent
6d73e50aa4
commit
9237f5a947
383
html/search.ejs
383
html/search.ejs
@ -515,22 +515,26 @@ Web </a>
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<%
|
<%
|
||||||
|
<%
|
||||||
const query = q.toLowerCase().trim();
|
const query = (q || '').toLowerCase().trim();
|
||||||
let answer = '';
|
let answer = '';
|
||||||
|
|
||||||
function isMathExpression(query) {
|
function isMathExpression(s) {
|
||||||
return /^[0-9\s\+\-\*\/\.\x]+$/.test(query);
|
return /^[0-9\s+\-*/.x]+$/.test(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (/^[0-9\s+\-*/.x]+$/.test(query)) {
|
function evaluateMathExpression(src) {
|
||||||
const expr = query.replace(/\s+/g, '');
|
const expr = src.replace(/\s+/g, '');
|
||||||
answer = expr === '9+10' ? '21' : (() => {
|
if (expr === '9+10') return '21';
|
||||||
try { return eval(expr); } catch { return 'Invalid Expression'; }
|
try {
|
||||||
})();
|
// Safer than eval: no access to local scope; still only for simple arithmetic
|
||||||
return answer;
|
const val = Function('"use strict";return (' + expr + ')')();
|
||||||
|
return String(val);
|
||||||
|
} catch {
|
||||||
|
return 'Invalid Expression';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getCurrentDate() {
|
function getCurrentDate() {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
@ -538,152 +542,34 @@ function getCurrentDate() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getCurrentYear() {
|
function getCurrentYear() {
|
||||||
return new Date().getFullYear();
|
return String(new Date().getFullYear());
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTimeInTimezone(location) {
|
function getTimeInTimezone(location) {
|
||||||
const tzMap = {
|
const tzMap = {
|
||||||
"california": "America/Los_Angeles",
|
"california":"America/Los_Angeles","new york":"America/New_York","chicago":"America/Chicago","denver":"America/Denver","phoenix":"America/Phoenix","anchorage":"America/Anchorage","honolulu":"Pacific/Honolulu",
|
||||||
"new york": "America/New_York",
|
"london":"Europe/London","paris":"Europe/Paris","berlin":"Europe/Berlin","madrid":"Europe/Madrid","rome":"Europe/Rome","moscow":"Europe/Moscow","athens":"Europe/Athens",
|
||||||
"chicago": "America/Chicago",
|
"sydney":"Australia/Sydney","melbourne":"Australia/Melbourne","brisbane":"Australia/Brisbane","perth":"Australia/Perth",
|
||||||
"denver": "America/Denver",
|
"tokyo":"Asia/Tokyo","osaka":"Asia/Osaka","seoul":"Asia/Seoul","beijing":"Asia/Shanghai","shanghai":"Asia/Shanghai","hong kong":"Asia/Hong_Kong","taipei":"Asia/Taipei","bangkok":"Asia/Bangkok","jakarta":"Asia/Jakarta","delhi":"Asia/Kolkata","mumbai":"Asia/Kolkata","karachi":"Asia/Karachi",
|
||||||
"phoenix": "America/Phoenix",
|
"dubai":"Asia/Dubai","abu dhabi":"Asia/Dubai","riyadh":"Asia/Riyadh",
|
||||||
"anchorage": "America/Anchorage",
|
"johannesburg":"Africa/Johannesburg","cairo":"Africa/Cairo","nairobi":"Africa/Nairobi","lagos":"Africa/Lagos","algiers":"Africa/Algiers","casablanca":"Africa/Casablanca",
|
||||||
"honolulu": "Pacific/Honolulu",
|
"lisbon":"Europe/Lisbon","dublin":"Europe/Dublin","zurich":"Europe/Zurich","vienna":"Europe/Vienna","stockholm":"Europe/Stockholm","oslo":"Europe/Oslo","helsinki":"Europe/Helsinki","prague":"Europe/Prague","budapest":"Europe/Budapest","warsaw":"Europe/Warsaw","bucharest":"Europe/Bucharest","sofia":"Europe/Sofia","zagreb":"Europe/Zagreb","belgrade":"Europe/Belgrade","sarajevo":"Europe/Sarajevo","podgorica":"Europe/Podgorica","ljubljana":"Europe/Ljubljana","tirana":"Europe/Tirane","valletta":"Europe/Malta","andorra la vella":"Europe/Andorra","monaco":"Europe/Monaco","luxembourg":"Europe/Luxembourg","bratislava":"Europe/Bratislava","vilnius":"Europe/Vilnius","riga":"Europe/Riga","tallinn":"Europe/Tallinn","istanbul":"Europe/Istanbul",
|
||||||
"london": "Europe/London",
|
"jerusalem":"Asia/Jerusalem","amman":"Asia/Amman","beirut":"Asia/Beirut","damascus":"Asia/Damascus","baghdad":"Asia/Baghdad","tehran":"Asia/Tehran","islamabad":"Asia/Karachi","kathmandu":"Asia/Kathmandu","thimphu":"Asia/Thimphu","dhaka":"Asia/Dhaka","yangon":"Asia/Yangon","hanoi":"Asia/Ho_Chi_Minh","ho chi minh city":"Asia/Ho_Chi_Minh","manila":"Asia/Manila","singapore":"Asia/Singapore","kuala lumpur":"Asia/Kuala_Lumpur","colombo":"Asia/Colombo",
|
||||||
"paris": "Europe/Paris",
|
"bagotville":"America/Montreal","toronto":"America/Toronto","vancouver":"America/Vancouver","mexico city":"America/Mexico_City","guadalajara":"America/Mexico_City","monterrey":"America/Monterrey",
|
||||||
"berlin": "Europe/Berlin",
|
"sao paulo":"America/Sao_Paulo","buenos aires":"America/Argentina/Buenos_Aires","santiago":"America/Santiago","rio de janeiro":"America/Sao_Paulo","caracas":"America/Caracas","bogota":"America/Bogota","lima":"America/Lima","quito":"America/Quito","georgetown":"America/Guyana","paramaribo":"America/Paramaribo","cayenne":"America/Cayenne","kingston":"America/Jamaica","port_of_spain":"America/Port_of_Spain","st johns":"America/St_Johns",
|
||||||
"madrid": "Europe/Madrid",
|
"midway":"Pacific/Midway","apia":"Pacific/Apia","nuku alofa":"Pacific/Tongatapu","tarawa":"Pacific/Tarawa","funafuti":"Pacific/Funafuti","suva":"Pacific/Fiji","chatham":"Pacific/Chatham","pitcairn":"Pacific/Pitcairn","galapagos":"Pacific/Galapagos","easter island":"Pacific/Easter","honiara":"Pacific/Guadalcanal","port vila":"Pacific/Efate","palikir":"Pacific/Pohnpei","palau":"Pacific/Palau",
|
||||||
"rome": "Europe/Rome",
|
"mcmurdo":"Antarctica/McMurdo","rothera":"Antarctica/Rothera","troll":"Antarctica/Troll","davis":"Antarctica/Davis","casey":"Antarctica/Casey","mawson":"Antarctica/Mawson","vostok":"Antarctica/Vostok","syowa":"Antarctica/Syowa",
|
||||||
"moscow": "Europe/Moscow",
|
"gmt":"Etc/GMT","utc":"UTC"
|
||||||
"athens": "Europe/Athens",
|
};
|
||||||
"sydney": "Australia/Sydney",
|
|
||||||
"melbourne": "Australia/Melbourne",
|
|
||||||
"brisbane": "Australia/Brisbane",
|
|
||||||
"perth": "Australia/Perth",
|
|
||||||
"tokyo": "Asia/Tokyo",
|
|
||||||
"osaka": "Asia/Osaka",
|
|
||||||
"seoul": "Asia/Seoul",
|
|
||||||
"beijing": "Asia/Shanghai",
|
|
||||||
"shanghai": "Asia/Shanghai",
|
|
||||||
"hong kong": "Asia/Hong_Kong",
|
|
||||||
"taipei": "Asia/Taipei",
|
|
||||||
"bangkok": "Asia/Bangkok",
|
|
||||||
"jakarta": "Asia/Jakarta",
|
|
||||||
"delhi": "Asia/Kolkata",
|
|
||||||
"mumbai": "Asia/Kolkata",
|
|
||||||
"karachi": "Asia/Karachi",
|
|
||||||
"dubai": "Asia/Dubai",
|
|
||||||
"abu dhabi": "Asia/Dubai",
|
|
||||||
"riyadh": "Asia/Riyadh",
|
|
||||||
"johannesburg": "Africa/Johannesburg",
|
|
||||||
"cairo": "Africa/Cairo",
|
|
||||||
"nairobi": "Africa/Nairobi",
|
|
||||||
"lagos": "Africa/Lagos",
|
|
||||||
"algiers": "Africa/Algiers",
|
|
||||||
"casablanca": "Africa/Casablanca",
|
|
||||||
"lisbon": "Europe/Lisbon",
|
|
||||||
"dublin": "Europe/Dublin",
|
|
||||||
"zurich": "Europe/Zurich",
|
|
||||||
"vienna": "Europe/Vienna",
|
|
||||||
"stockholm": "Europe/Stockholm",
|
|
||||||
"oslo": "Europe/Oslo",
|
|
||||||
"helsinki": "Europe/Helsinki",
|
|
||||||
"prague": "Europe/Prague",
|
|
||||||
"budapest": "Europe/Budapest",
|
|
||||||
"warsaw": "Europe/Warsaw",
|
|
||||||
"bucharest": "Europe/Bucharest",
|
|
||||||
"sofia": "Europe/Sofia",
|
|
||||||
"zagreb": "Europe/Zagreb",
|
|
||||||
"belgrade": "Europe/Belgrade",
|
|
||||||
"sarajevo": "Europe/Sarajevo",
|
|
||||||
"podgorica": "Europe/Podgorica",
|
|
||||||
"ljubljana": "Europe/Ljubljana",
|
|
||||||
"tirana": "Europe/Tirane",
|
|
||||||
"valletta": "Europe/Malta",
|
|
||||||
"andorra la vella": "Europe/Andorra",
|
|
||||||
"monaco": "Europe/Monaco",
|
|
||||||
"luxembourg": "Europe/Luxembourg",
|
|
||||||
"bratislava": "Europe/Bratislava",
|
|
||||||
"vilnius": "Europe/Vilnius",
|
|
||||||
"riga": "Europe/Riga",
|
|
||||||
"tallinn": "Europe/Tallinn",
|
|
||||||
"istanbul": "Europe/Istanbul",
|
|
||||||
"jerusalem": "Asia/Jerusalem",
|
|
||||||
"amman": "Asia/Amman",
|
|
||||||
"beirut": "Asia/Beirut",
|
|
||||||
"damascus": "Asia/Damascus",
|
|
||||||
"baghdad": "Asia/Baghdad",
|
|
||||||
"tehran": "Asia/Tehran",
|
|
||||||
"islamabad": "Asia/Karachi",
|
|
||||||
"kathmandu": "Asia/Kathmandu",
|
|
||||||
"thimphu": "Asia/Thimphu",
|
|
||||||
"dhaka": "Asia/Dhaka",
|
|
||||||
"yangon": "Asia/Yangon",
|
|
||||||
"hanoi": "Asia/Ho_Chi_Minh",
|
|
||||||
"ho chi minh city": "Asia/Ho_Chi_Minh",
|
|
||||||
"manila": "Asia/Manila",
|
|
||||||
"singapore": "Asia/Singapore",
|
|
||||||
"kuala lumpur": "Asia/Kuala_Lumpur",
|
|
||||||
"colombo": "Asia/Colombo",
|
|
||||||
"bagotville": "America/Montreal",
|
|
||||||
"toronto": "America/Toronto",
|
|
||||||
"vancouver": "America/Vancouver",
|
|
||||||
"mexico city": "America/Mexico_City",
|
|
||||||
"guadalajara": "America/Mexico_City",
|
|
||||||
"monterrey": "America/Monterrey",
|
|
||||||
"sao paulo": "America/Sao_Paulo",
|
|
||||||
"buenos aires": "America/Argentina/Buenos_Aires",
|
|
||||||
"santiago": "America/Santiago",
|
|
||||||
"rio de janeiro": "America/Sao_Paulo",
|
|
||||||
"caracas": "America/Caracas",
|
|
||||||
"bogota": "America/Bogota",
|
|
||||||
"lima": "America/Lima",
|
|
||||||
"quito": "America/Quito",
|
|
||||||
"georgetown": "America/Guyana",
|
|
||||||
"paramaribo": "America/Paramaribo",
|
|
||||||
"cayenne": "America/Cayenne",
|
|
||||||
"kingston": "America/Jamaica",
|
|
||||||
"port_of_spain": "America/Port_of_Spain",
|
|
||||||
"st johns": "America/St_Johns",
|
|
||||||
"midway": "Pacific/Midway",
|
|
||||||
"apia": "Pacific/Apia",
|
|
||||||
"nuku alofa": "Pacific/Tongatapu",
|
|
||||||
"tarawa": "Pacific/Tarawa",
|
|
||||||
"funafuti": "Pacific/Funafuti",
|
|
||||||
"suva": "Pacific/Fiji",
|
|
||||||
"chatham": "Pacific/Chatham",
|
|
||||||
"pitcairn": "Pacific/Pitcairn",
|
|
||||||
"galapagos": "Pacific/Galapagos",
|
|
||||||
"easter island": "Pacific/Easter",
|
|
||||||
"honiara": "Pacific/Guadalcanal",
|
|
||||||
"port vila": "Pacific/Efate",
|
|
||||||
"palikir": "Pacific/Pohnpei",
|
|
||||||
"palau": "Pacific/Palau",
|
|
||||||
"mcmurdo": "Antarctica/McMurdo",
|
|
||||||
"rothera": "Antarctica/Rothera",
|
|
||||||
"troll": "Antarctica/Troll",
|
|
||||||
"davis": "Antarctica/Davis",
|
|
||||||
"casey": "Antarctica/Casey",
|
|
||||||
"mawson": "Antarctica/Mawson",
|
|
||||||
"vostok": "Antarctica/Vostok",
|
|
||||||
"syowa": "Antarctica/Syowa",
|
|
||||||
"gmt": "Etc/GMT",
|
|
||||||
"utc": "UTC"
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
const timezone = tzMap[location.toLowerCase()];
|
const timezone = tzMap[location.toLowerCase()];
|
||||||
if (!timezone) {
|
if (!timezone) return null;
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const options = { timeZone: timezone, timeStyle: 'medium', hour12: false };
|
const options = { timeZone: timezone, timeStyle: 'medium', hour12: false };
|
||||||
return now.toLocaleTimeString('en-US', options);
|
return now.toLocaleTimeString('en-US', options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function randomCompliment() {
|
function randomCompliment() {
|
||||||
const compliments = [
|
const compliments = [
|
||||||
"You’re an awesome friend.",
|
"You’re an awesome friend.",
|
||||||
@ -706,71 +592,25 @@ function randomEncouragement() {
|
|||||||
return encourages[Math.floor(Math.random() * encourages.length)];
|
return encourages[Math.floor(Math.random() * encourages.length)];
|
||||||
}
|
}
|
||||||
|
|
||||||
function base64Encode(str) {
|
function base64Encode(str) { return btoa(str); }
|
||||||
return btoa(str);
|
function base64Decode(str) { try { return atob(str); } catch { return 'Invalid Base64'; } }
|
||||||
}
|
function hexToDec(str) { return parseInt(str.replace(/^0x/, ''), 16).toString(); }
|
||||||
|
function decToHex(num) { return Number(num).toString(16); }
|
||||||
function base64Decode(str) {
|
function textToCharCodes(text) { return text.split('').map(c => c.charCodeAt(0)).join(' '); }
|
||||||
try {
|
function charCodesToText(codes) { return String.fromCharCode(...codes.split(/\s+/).map(n => +n)); }
|
||||||
return atob(str);
|
function countWords(text) { return text.trim().split(/\s+/).length; }
|
||||||
} catch {
|
function titleCase(text) { return text.split(' ').map(w => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()).join(' '); }
|
||||||
return 'Invalid Base64';
|
function slugify(text) { return text.toLowerCase().trim().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, ''); }
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function hexToDec(str) {
|
|
||||||
return parseInt(str.replace(/^0x/, ''), 16).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
function decToHex(num) {
|
|
||||||
return Number(num).toString(16);
|
|
||||||
}
|
|
||||||
|
|
||||||
function textToCharCodes(text) {
|
|
||||||
return text.split('').map(c => c.charCodeAt(0)).join(' ');
|
|
||||||
}
|
|
||||||
|
|
||||||
function charCodesToText(codes) {
|
|
||||||
return String.fromCharCode(...codes.split(/\s+/).map(n => +n));
|
|
||||||
}
|
|
||||||
|
|
||||||
function countWords(text) {
|
|
||||||
return text.trim().split(/\s+/).length;
|
|
||||||
}
|
|
||||||
|
|
||||||
function titleCase(text) {
|
|
||||||
return text
|
|
||||||
.split(' ')
|
|
||||||
.map(w => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase())
|
|
||||||
.join(' ');
|
|
||||||
}
|
|
||||||
|
|
||||||
function slugify(text) {
|
|
||||||
return text
|
|
||||||
.toLowerCase()
|
|
||||||
.trim()
|
|
||||||
.replace(/[^a-z0-9]+/g, '-')
|
|
||||||
.replace(/^-+|-+$/g, '');
|
|
||||||
}
|
|
||||||
|
|
||||||
function isPrime(n) {
|
function isPrime(n) {
|
||||||
n = Number(n);
|
n = Number(n);
|
||||||
if (n < 2) return false;
|
if (n < 2) return false;
|
||||||
for (let i = 2; i <= Math.sqrt(n); i++) {
|
for (let i = 2; i <= Math.sqrt(n); i++) if (n % i === 0) return false;
|
||||||
if (n % i === 0) return false;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function gcd(a, b) {
|
function gcd(a, b) { a = Math.abs(a); b = Math.abs(b); while (b) [a, b] = [b, a % b]; return a; }
|
||||||
a = Math.abs(a); b = Math.abs(b);
|
function lcm(a, b) { return Math.abs(a * b) / gcd(a, b); }
|
||||||
while (b) [a, b] = [b, a % b];
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
|
|
||||||
function lcm(a, b) {
|
|
||||||
return Math.abs(a * b) / gcd(a, b);
|
|
||||||
}
|
|
||||||
|
|
||||||
function fibonacci(n) {
|
function fibonacci(n) {
|
||||||
n = Number(n);
|
n = Number(n);
|
||||||
@ -783,9 +623,7 @@ function fibonacci(n) {
|
|||||||
function generatePassword(length = 8) {
|
function generatePassword(length = 8) {
|
||||||
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()';
|
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()';
|
||||||
let pw = '';
|
let pw = '';
|
||||||
for (let i = 0; i < length; i++) {
|
for (let i = 0; i < length; i++) pw += chars.charAt(Math.floor(Math.random() * chars.length));
|
||||||
pw += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
||||||
}
|
|
||||||
return pw;
|
return pw;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -793,76 +631,45 @@ function daysUntil(dateStr) {
|
|||||||
const now = new Date();
|
const now = new Date();
|
||||||
const then = new Date(dateStr);
|
const then = new Date(dateStr);
|
||||||
const diff = then - now;
|
const diff = then - now;
|
||||||
return diff > 0
|
return diff > 0 ? Math.ceil(diff / (1000 * 60 * 60 * 24)) + ' days' : 'Date passed';
|
||||||
? Math.ceil(diff / (1000 * 60 * 60 * 24)) + ' days'
|
|
||||||
: 'Date passed';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateUUID() {
|
function generateUUID() {
|
||||||
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(
|
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c =>
|
||||||
/[018]/g,
|
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
|
||||||
c => (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateRandomString(length = 8) {
|
function generateRandomString(length = 8) {
|
||||||
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||||
let s = '';
|
let s = '';
|
||||||
for (let i = 0; i < length; i++) {
|
for (let i = 0; i < length; i++) s += chars.charAt(Math.floor(Math.random() * chars.length));
|
||||||
s += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
||||||
}
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const emojiMap = {
|
||||||
const emojiMap = {
|
"grinning face":"😀","grin":"😁","smiley":"😃","smile":"😄","sweat smile":"😅","joy":"😂","rofl":"🤣","relaxed":"☺️","blush":"😊","innocent":"😇",
|
||||||
"grinning face":"😀","grin":"😁","smiley":"😃","smile":"😄","sweat smile":"😅",
|
"slightly_smiling_face":"🙂","upside_down":"🙃","wink":"😉","relieved":"😌","heart eyes":"😍","kissing_heart":"😘","kissing":"😗","kissing_smiling_eyes":"😙","kissing_closed_eyes":"😚",
|
||||||
"joy":"😂","rofl":"🤣","relaxed":"☺️","blush":"😊","innocent":"😇",
|
"yum":"😋","stuck out tongue":"😛","stuck out tongue wink":"😜","stuck out tongue closed eyes":"😝","money_mouth":"🤑","hug":"🤗","nerd":"🤓","sunglasses":"😎","star_struck":"🤩",
|
||||||
"slightly_smiling_face":"🙂","upside_down":"🙃","wink":"😉","relieved":"😌",
|
"thinking":"🤔","zipper_mouth":"🤐","raised_eyebrow":"🤨","neutral":"😐","expressionless":"😑","no_mouth":"😶","roll_eyes":"🙄","smirk":"😏","persevere":"😣","disappointed_relieved":"😥",
|
||||||
"heart eyes":"😍","kissing_heart":"😘","kissing":"😗","kissing_smiling_eyes":"😙",
|
"cold_sweat":"😰","pensive":"😔","confused":"😕","worried":"😟","slightly_frowning":"🙁","frowning":"☹️","anguished":"😧","open_mouth":"😮","grimacing":"😬","hushed":"😯","astonished":"😲",
|
||||||
"kissing_closed_eyes":"😚","yum":"😋","stuck out tongue":"😛","stuck out tongue wink":"😜",
|
"flushed":"😳","pleading":"🥺","frowning2":"😦","anguished2":"😧","cry":"😢","disappointed":"😞","scream":"😱","fearful":"😨","tired_face":"😫","weary":"😩","triumph":"😤",
|
||||||
"stuck out tongue closed eyes":"😝","money_mouth":"🤑","hug":"🤗","nerd":"🤓",
|
"angry":"😠","rage":"😡","poop":"💩","thumbsup":"👍","thumbsdown":"👎","clap":"👏","raised_hands":"🙌","pray":"🙏","muscle":"💪","eyes":"👀","ear":"👂","nose":"👃","tongue":"👅",
|
||||||
"sunglasses":"😎","star_struck":"🤩","thinking":"🤔","zipper_mouth":"🤐",
|
"lips":"👄","kiss":"💋","crown":"👑","womans hat":"👒","eyeglasses":"👓","necktie":"👔","shirt":"👕","jeans":"👖","dress":"👗","kimono":"👘","bikini":"👙","sandal":"👡","boot":"👢",
|
||||||
"raised_eyebrow":"🤨","neutral":"😐","expressionless":"😑","no_mouth":"😶",
|
"mans shoe":"👞","high heel":"👠","sock":"🧦","gloves":"🧤","scarf":"🧣","tophat":"🎩","billed cap":"🧢","flag us":"🇺🇸","flag gb":"🇬🇧","flag ca":"🇨🇦","flag de":"🇩🇪","flag fr":"🇫🇷",
|
||||||
"roll_eyes":"🙄","smirk":"😏","persevere":"😣","disappointed_relieved":"😥",
|
"flag es":"🇪🇸","flag it":"🇮🇹","flag jp":"🇯🇵","flag cn":"🇨🇳","flag in":"🇮🇳","flag br":"🇧🇷","flag ru":"🇷🇺","flag za":"🇿🇦","flag au":"🇦🇺","flag nz":"🇳🇿","flag ng":"🇳🇬","flag eg":"🇪🇬",
|
||||||
"cold_sweat":"😰","pensive":"😔","confused":"😕","worried":"😟","slightly_frowning":"🙁",
|
"flag ar":"🇦🇷","flag mx":"🇲🇽","flag kr":"🇰🇷","flag tr":"🇹🇷",
|
||||||
"frowning":"☹️","anguished":"😧","open_mouth":"😮","grimacing":"😬","hushed":"😯",
|
"dog face":"🐶","cat face":"🐱","mouse face":"🐭","hamster":"🐹","rabbit":"🐰","fox face":"🦊","bear face":"🐻","koala":"🐨","tiger face":"🐯","lion face":"🦁","cow face":"🐮","pig face":"🐷",
|
||||||
"astonished":"😲","flushed":"😳","pleading":"🥺","frowning2":"😦","anguished2":"😧",
|
"frog face":"🐸","octopus":"🐙","monkey face":"🐵","chicken":"🐔","penguin":"🐧","bird":"🐦","baby chick":"🐤","hatching chick":"🐣",
|
||||||
"cry":"😢","disappointed":"😞","scream":"😱","fearful":"😨","tired_face":"😫",
|
"sun":"☀️","moon":"🌙","star":"⭐️","cloud":"☁️","umbrella":"☂️","snowflake":"❄️","fire":"🔥","droplet":"💧","ocean":"🌊","volcano":"🌋","cactus":"🌵","palm tree":"🌴","evergreen tree":"🌲",
|
||||||
"weary":"😩","triumph":"😤","angry":"😠","rage":"😡","poop":"💩","thumbsup":"👍",
|
"deciduous tree":"🌳","fallen leaf":"🍂","maple leaf":"🍁","seedling":"🌱","flower":"🌸","rose":"🌹","sunflower":"🌻","blossom":"🌼",
|
||||||
"thumbsdown":"👎","clap":"👏","raised_hands":"🙌","pray":"🙏","muscle":"💪","eyes":"👀",
|
"grapes":"🍇","watermelon":"🍉","tangerine":"🍊","banana":"🍌","pineapple":"🍍","apple":"🍎","pear":"🍐","peach":"🍑","strawberry":"🍓","cherries":"🍒","mango":"🥭","lemon":"🍋",
|
||||||
"ear":"👂","nose":"👃","tongue":"👅","lips":"👄","kiss":"💋","crown":"👑","womans hat":"👒",
|
"coffee":"☕️","tea":"🍵","beer":"🍺","wine glass":"🍷","cocktail":"🍸","tropical drink":"🍹","birthday cake":"🎂","pizza":"🍕","hamburger":"🍔","fries":"🍟","hot dog":"🌭","taco":"🌮",
|
||||||
"eyeglasses":"👓","necktie":"👔","shirt":"👕","jeans":"👖","dress":"👗","kimono":"👘",
|
"burrito":"🌯","popcorn":"🍿","chocolate bar":"🍫","candy":"🍬","lollipop":"🍭","honey pot":"🍯"
|
||||||
"bikini":"👙","sandal":"👡","boot":"👢","mans shoe":"👞","high heel":"👠","sock":"🧦",
|
|
||||||
"gloves":"🧤","scarf":"🧣","tophat":"🎩","billed cap":"🧢","flag us":"🇺🇸","flag gb":"🇬🇧",
|
|
||||||
"flag ca":"🇨🇦","flag de":"🇩🇪","flag fr":"🇫🇷","flag es":"🇪🇸","flag it":"🇮🇹","flag jp":"🇯🇵",
|
|
||||||
"flag cn":"🇨🇳","flag in":"🇮🇳","flag br":"🇧🇷","flag ru":"🇷🇺","flag za":"🇿🇦","flag au":"🇦🇺",
|
|
||||||
"flag nz":"🇳🇿","flag ng":"🇳🇬","flag eg":"🇪🇬","flag ar":"🇦🇷","flag mx":"🇲🇽","flag kr":"🇰🇷",
|
|
||||||
"flag tr":"🇹🇷",
|
|
||||||
|
|
||||||
// animals
|
|
||||||
"dog face":"🐶","cat face":"🐱","mouse face":"🐭","hamster":"🐹","rabbit":"🐰",
|
|
||||||
"fox face":"🦊","bear face":"🐻","koala":"🐨","tiger face":"🐯","lion face":"🦁",
|
|
||||||
"cow face":"🐮","pig face":"🐷","frog face":"🐸","octopus":"🐙","monkey face":"🐵",
|
|
||||||
"chicken":"🐔","penguin":"🐧","bird":"🐦","baby chick":"🐤","hatching chick":"🐣",
|
|
||||||
|
|
||||||
// nature
|
|
||||||
"sun":"☀️","moon":"🌙","star":"⭐️","cloud":"☁️","umbrella":"☂️","snowflake":"❄️",
|
|
||||||
"fire":"🔥","droplet":"💧","ocean":"🌊","volcano":"🌋","cactus":"🌵","palm tree":"🌴",
|
|
||||||
"evergreen tree":"🌲","deciduous tree":"🌳","fallen leaf":"🍂","maple leaf":"🍁",
|
|
||||||
"seedling":"🌱","flower":"🌸","rose":"🌹","sunflower":"🌻","blossom":"🌼",
|
|
||||||
|
|
||||||
//food
|
|
||||||
"grapes":"🍇","watermelon":"🍉","tangerine":"🍊","banana":"🍌","pineapple":"🍍",
|
|
||||||
"apple":"🍎","pear":"🍐","peach":"🍑","strawberry":"🍓","cherries":"🍒","mango":"🥭",
|
|
||||||
"lemon":"🍋","coffee":"☕️","tea":"🍵","beer":"🍺","wine glass":"🍷","cocktail":"🍸",
|
|
||||||
"tropical drink":"🍹","birthday cake":"🎂","pizza":"🍕","hamburger":"🍔","fries":"🍟",
|
|
||||||
"hot dog":"🌭","taco":"🌮","burrito":"🌯","popcorn":"🍿","chocolate bar":"🍫",
|
|
||||||
"candy":"🍬","lollipop":"🍭","honey pot":"🍯"
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
let m;
|
let m;
|
||||||
|
|
||||||
if (isMathExpression(query)) {
|
if (isMathExpression(query)) {
|
||||||
answer = evaluateMathExpression(query);
|
answer = evaluateMathExpression(query);
|
||||||
} else if (query.includes('date') || query.includes('what date is it')) {
|
} else if (query.includes('date') || query.includes('what date is it')) {
|
||||||
@ -871,7 +678,7 @@ if (isMathExpression(query)) {
|
|||||||
answer = getCurrentYear();
|
answer = getCurrentYear();
|
||||||
} else if (query.includes('what time is it in')) {
|
} else if (query.includes('what time is it in')) {
|
||||||
const location = query.split('what time is it in')[1].trim();
|
const location = query.split('what time is it in')[1].trim();
|
||||||
answer = getTimeInTimezone(location);
|
answer = getTimeInTimezone(location) || 'Unknown location';
|
||||||
} else if (query.includes('what time is it')) {
|
} else if (query.includes('what time is it')) {
|
||||||
answer = new Date().toLocaleTimeString();
|
answer = new Date().toLocaleTimeString();
|
||||||
} else if (query.includes('day') || query.includes('what day is it')) {
|
} else if (query.includes('day') || query.includes('what day is it')) {
|
||||||
@ -885,9 +692,7 @@ if (isMathExpression(query)) {
|
|||||||
} else if (query.includes('am i cute') || query.includes('am i a cutie?')) {
|
} else if (query.includes('am i cute') || query.includes('am i a cutie?')) {
|
||||||
answer = "yesh :3 u are ";
|
answer = "yesh :3 u are ";
|
||||||
} else if (query.includes('am i a good girl') || query.includes('am i a good boy?')) {
|
} else if (query.includes('am i a good girl') || query.includes('am i a good boy?')) {
|
||||||
answer = query.includes('girl')
|
answer = query.includes('girl') ? "yesh :3 u are a good girl" : "yesh :3 u are a good boy";
|
||||||
? "yesh :3 u are a good girl"
|
|
||||||
: "yesh :3 u are a good boy";
|
|
||||||
} else if (query.includes('ur hot') || query.includes('you are hot')) {
|
} else if (query.includes('ur hot') || query.includes('you are hot')) {
|
||||||
answer = "jrifyehgyerfgu9wdswgfsafgydwgbfwdfge >~< ";
|
answer = "jrifyehgyerfgu9wdswgfsafgydwgbfwdfge >~< ";
|
||||||
} else if (/^(?:emoji\s+(.+)|(.+)\s+emoji)$/.test(query)) {
|
} else if (/^(?:emoji\s+(.+)|(.+)\s+emoji)$/.test(query)) {
|
||||||
@ -895,9 +700,7 @@ if (isMathExpression(query)) {
|
|||||||
let name = (match[1] || match[2]).trim().toLowerCase();
|
let name = (match[1] || match[2]).trim().toLowerCase();
|
||||||
const keySpace = name.replace(/_/g, ' ');
|
const keySpace = name.replace(/_/g, ' ');
|
||||||
const keyUnderscore = name.replace(/\s+/g, '_');
|
const keyUnderscore = name.replace(/\s+/g, '_');
|
||||||
answer = emojiMap[keySpace]
|
answer = emojiMap[keySpace] || emojiMap[keyUnderscore] || 'Unknown emoji';
|
||||||
|| emojiMap[keyUnderscore]
|
|
||||||
|| 'Unknown emoji';
|
|
||||||
} else if (query.includes('compliment')) {
|
} else if (query.includes('compliment')) {
|
||||||
answer = randomCompliment();
|
answer = randomCompliment();
|
||||||
} else if (query.includes('encouragement') || query.includes('encourage me')) {
|
} else if (query.includes('encouragement') || query.includes('encourage me')) {
|
||||||
@ -908,28 +711,29 @@ if (isMathExpression(query)) {
|
|||||||
answer = base64Decode(query.slice(14));
|
answer = base64Decode(query.slice(14));
|
||||||
} else if ((m = /0x[0-9a-f]+/i.exec(query))) {
|
} else if ((m = /0x[0-9a-f]+/i.exec(query))) {
|
||||||
answer = hexToDec(m[0]);
|
answer = hexToDec(m[0]);
|
||||||
} else if (query.match(/\d+\s+to\s+hex/i)) {
|
} else if (/\d+\s+to\s+hex/i.test(query)) {
|
||||||
answer = decToHex(query.match(/\d+/)[0]);
|
answer = decToHex(query.match(/\d+/)[0]);
|
||||||
} else if (query.startsWith('char codes for ')) {
|
} else if (query.startsWith('char codes for ')) {
|
||||||
answer = textToCharCodes(query.slice(15));
|
answer = textToCharCodes(query.slice(15));
|
||||||
} else if (query.startsWith('text from codes ')) {
|
} else if (query.startsWith('text from codes ')) {
|
||||||
answer = charCodesToText(query.slice(16));
|
answer = charCodesToText(query.slice(16));
|
||||||
} else if (query.startsWith('word count of ')) {
|
} else if (query.startsWith('word count of ')) {
|
||||||
answer = countWords(query.slice(14)).toString();
|
answer = String(countWords(query.slice(14)));
|
||||||
} else if (query.startsWith('titlecase ')) {
|
} else if (query.startsWith('titlecase ')) {
|
||||||
answer = titleCase(query.slice(10));
|
answer = titleCase(query.slice(10));
|
||||||
} else if (query.startsWith('slugify ')) {
|
} else if (query.startsWith('slugify ')) {
|
||||||
answer = slugify(query.slice(8));
|
answer = slugify(query.slice(8));
|
||||||
} else if (query.match(/\bprime\b/)) {
|
} else if (/\bprime\b/.test(query)) {
|
||||||
answer = isPrime(query.match(/\d+/)[0]) ? 'Yes' : 'No';
|
const n = query.match(/\d+/);
|
||||||
|
answer = n ? (isPrime(n[0]) ? 'Yes' : 'No') : 'No';
|
||||||
} else if (query.includes('gcd of ')) {
|
} else if (query.includes('gcd of ')) {
|
||||||
const nums = query.match(/\d+/g);
|
const nums = query.match(/\d+/g);
|
||||||
answer = gcd(nums[0], nums[1]).toString();
|
answer = nums ? String(gcd(nums[0], nums[1])) : 'Invalid';
|
||||||
} else if (query.includes('lcm of ')) {
|
} else if (query.includes('lcm of ')) {
|
||||||
const nums = query.match(/\d+/g);
|
const nums = query.match(/\d+/g);
|
||||||
answer = lcm(nums[0], nums[1]).toString();
|
answer = nums ? String(lcm(nums[0], nums[1])) : 'Invalid';
|
||||||
} else if (query.match(/fib(?:onacci)?\s*\d+/i)) {
|
} else if (/fib(?:onacci)?\s*\d+/i.test(query)) {
|
||||||
answer = fibonacci(query.match(/\d+/)[0]).toString();
|
answer = String(fibonacci(query.match(/\d+/)[0]));
|
||||||
} else if (query.startsWith('generate password')) {
|
} else if (query.startsWith('generate password')) {
|
||||||
const n = query.match(/\d+/);
|
const n = query.match(/\d+/);
|
||||||
answer = generatePassword(n ? Number(n[0]) : undefined);
|
answer = generatePassword(n ? Number(n[0]) : undefined);
|
||||||
@ -942,7 +746,6 @@ if (isMathExpression(query)) {
|
|||||||
answer = generateRandomString(n ? Number(n[0]) : undefined);
|
answer = generateRandomString(n ? Number(n[0]) : undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const upsellMessages = [
|
const upsellMessages = [
|
||||||
"[new] Try searching 'What's 4+4?'",
|
"[new] Try searching 'What's 4+4?'",
|
||||||
"[new] Ask 'What's the date today?'",
|
"[new] Ask 'What's the date today?'",
|
||||||
@ -952,18 +755,22 @@ const upsellMessages = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
const showUpsell = !answer && Math.random() < 0.1;
|
const showUpsell = !answer && Math.random() < 0.1;
|
||||||
const randomUpsellMessage = showUpsell ? upsellMessages[Math.floor(Math.random() * upsellMessages.length)] : '';
|
const randomUpsellMessage = showUpsell
|
||||||
|
? upsellMessages[Math.floor(Math.random() * upsellMessages.length)]
|
||||||
|
: '';
|
||||||
|
|
||||||
function extractQueryFromUpsellMessage(message) {
|
function extractQueryFromUpsellMessage(message) {
|
||||||
return message.replace("[new] Try searching '", "")
|
return message
|
||||||
.replace("[new] Try '", "")
|
.replace("[new] Try searching '", "")
|
||||||
.replace("[new] Ask '", "")
|
.replace("[new] Try '", "")
|
||||||
.replace("[new] Try ", "")
|
.replace("[new] Ask '", "")
|
||||||
.replace("'", "")
|
.replace("[new] Try ", "")
|
||||||
.replace("?", "")
|
.replace("'", "")
|
||||||
.trim();
|
.replace("?", "")
|
||||||
|
.trim();
|
||||||
}
|
}
|
||||||
|
%>
|
||||||
|
|
||||||
%>
|
%>
|
||||||
%>
|
%>
|
||||||
<% if (answer) { %>
|
<% if (answer) { %>
|
||||||
@ -982,7 +789,7 @@ function extractQueryFromUpsellMessage(message) {
|
|||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
word-break: break-word;
|
word-break: break-word;
|
||||||
"
|
"
|
||||||
><%= answer %></span>
|
><%= String(answer || '') %></span>
|
||||||
<div style="display: flex; gap: 1em;">
|
<div style="display: flex; gap: 1em;">
|
||||||
<button
|
<button
|
||||||
id="copy-btn"
|
id="copy-btn"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user