User:Davidboo25/common.js: Difference between revisions

From Melvor Idle
(testing js)
 
No edit summary
Line 1: Line 1:
const combatLevel  = {
$(function () {
  displayValue: '0',
var myElement = document.getElementById('calculator');
  firstOperand: null,
myElement.innerHTML = 'any HTMLasdasdasdasdasd';
  waitingForSecondOperand: false,
}());
  operator: null,
};
 
 
 
function handleOperator(nextOperator) {
  const { firstOperand, displayValue, operator } = combatLevel
  const inputValue = parseFloat(displayValue);
 
    const result = inputValue + 1
 
    combatLevel.displayValue = String(result);
    combatLevel.firstOperand = result;
 
  combatLevel.operator = nextOperator;
}
 
 
 
// TODO, do somthing in here so that every update display, we grab every text box's values
// and then store it in a value.
  //  we can then take the values and add them up and do combat math on them.
function updateDisplay() {
  const display = document.querySelector('.output_screen');
  display.value = combatLevel.displayValue;
}
 
updateDisplay();
 
const keys = document.querySelector('.equals_button');
keys.addEventListener('click', (event) => {
  const { target } = event;
  if (!target.matches('button')) {
    return;
  }
 
  if (target.classList.contains('operator')) {
    handleOperator(target.value);
updateDisplay();
    return;
  }
 
 
  inputDigit(target.value);
  updateDisplay();
});

Revision as of 03:59, 2 April 2021

$(function () {
	var myElement = document.getElementById('calculator');
	myElement.innerHTML = 'any HTMLasdasdasdasdasd';
}());