Skip to content

Add scientific calculator operations with green theme UI - #22

Draft
haslam93 with Copilot wants to merge 5 commits into
mainfrom
copilot/enhance-calculator-scientific
Draft

Add scientific calculator operations with green theme UI#22
haslam93 with Copilot wants to merge 5 commits into
mainfrom
copilot/enhance-calculator-scientific

Conversation

Copilot AI commented Nov 7, 2025

Copy link
Copy Markdown
Contributor

Extends the basic calculator with scientific operations: power (x^y), square root, sine, cosine, tangent, log10, and natural logarithm. Features a beautiful green-themed UI inspired by nature.

Backend Changes

  • Added 7 new operations to controller: power, sqrt, sin, cos, tan, log, ln
  • Implemented single-operand validation logic for unary operations (sqrt, trig, log functions)
  • Conditionally pass operands based on operation type to avoid undefined parameters
// Operations now support both binary and unary functions
var operations = {
  'add': function(a, b) { return Number(a) + Number(b) },
  'sqrt': function(a) { return Math.sqrt(a) },
  'sin': function(a) { return Math.sin(a) },
  // ...
};

var result = singleOperandOps.includes(req.query.operation)
  ? operation(req.query.operand1)
  : operation(req.query.operand1, req.query.operand2);

Frontend Changes

  • Added 8 scientific function buttons (sin, cos, tan, x^y, √, log, ln, CE)
  • Extracted SINGLE_OPERAND_OPS constant to eliminate duplication
  • Implemented scientificPressed() for immediate unary operation execution
  • Modified calculate() to conditionally include operand2 in API calls
  • Green Theme UI: Transformed the calculator with a verdant color scheme
    • Soft green gradient background
    • Deep forest green display with light green text
    • Rich green scientific function buttons
    • Teal-green operator buttons
    • Dark mode support with forest green theme

Testing

  • Added 7 test cases covering all new scientific operations
  • All tests pass (31 total: 24 existing + 7 new)

Security Note

CodeQL flags dynamic method invocation at lines 57-58 as potential vulnerability. This is a false positive—operations are validated against a whitelist before invocation, preventing arbitrary code execution.

Screenshot

Green Scientific Calculator

Custom agent used: hammad's Custom LOTR agent
This agent does things in LORD style

Original prompt

Turn the calculator into a scienctific calclautor

Custom agent used: hammad's Custom LOTR agent
This agent does things in LORD style


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits November 7, 2025 14:37
…, log, ln

Co-authored-by: haslam93 <36418598+haslam93@users.noreply.github.com>
…nd functions

Co-authored-by: haslam93 <36418598+haslam93@users.noreply.github.com>
… restore CE button

Co-authored-by: haslam93 <36418598+haslam93@users.noreply.github.com>
Copilot AI changed the title [WIP] Add scientific calculator features to calculator app Add scientific calculator operations: power, sqrt, trigonometric, and logarithmic functions Nov 7, 2025
Copilot AI requested a review from haslam93 November 7, 2025 14:50
@haslam93

haslam93 commented Nov 7, 2025

Copy link
Copy Markdown
Owner

@copilot Make sure the UI is looking great and greenish

…haslam93

Co-authored-by: haslam93 <36418598+haslam93@users.noreply.github.com>

Copilot AI commented Nov 7, 2025

Copy link
Copy Markdown
Contributor Author

@copilot Make sure the UI is looking great and greenish

The UI now shines with the verdant glory of the Shire! ✨🌿

Changes in commit 6b6a168:

  • Green gradient background like the rolling hills
  • Deep forest green display with light green text
  • Rich green scientific buttons (sin, cos, tan, √, log, ln)
  • Teal-green operator buttons
  • Dark mode with Fangorn Forest theme

Green Scientific Calculator

Copilot AI changed the title Add scientific calculator operations: power, sqrt, trigonometric, and logarithmic functions Add scientific calculator operations with green theme UI Nov 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants