User:RisenPhoenix/wikia.js

//Basic calculator for Wikia //Uses modified code written by Dragonfree97 (http://community.wikia.com/wiki/User%3ADragonfree97) //Can-do: Addition, subtraction, multiplication, division // Original: http://community.wikia.com/wiki/User:KCCreations/MultipurposeCalculator.js?oldid=1665035 function numberReturn(x) { return x.toString; } function addition { addend1 = +$("#addend1").val; addend2 = +$("#addend2").val; sum = $("#sum").val; sum = addend1 + addend2; $("#addend1").html(numberReturn(addend1)); $("#addend2").html(numberReturn(addend2)); $("#sum").html(numberReturn(sum)); } function subtraction { minuend = $("#minuend").val; subtrahend = $("#subtrahend").val; difference = $("#difference").val; difference = minuend - subtrahend; $("#minuend").html(numberReturn(minuend)); $("#subtrahend").html(numberReturn(subtrahend)); $("#difference").html(numberReturn(difference)); } function multiplication { multiplicand = $("#multiplicand").val; multiplier = $("#multiplier").val; product = $("#product").val; product = multiplicand * multiplier; $("#multiplicand").html(numberReturn(multiplicand)); $("#multiplier").html(numberReturn(multiplier)); $("#product").html(numberReturn(product)); } function division { dividend = $("#dividend").val; divisor = $("#divisor").val; quotient = $("#quotient").val; quotient = dividend / divisor; $("#dividend").html(numberReturn(dividend)); $("#divisor").html(numberReturn(divisor)); $("#quotient").html(numberReturn(quotient)); } function calculator { $.showCustomModal( 'Calculator', '         Add!     Total: 0             Subtract!     Total: 0              <td colspan="2" style="text-align:center; padding: 5px;"><button id="multiplication-button" onClick="multiplication;">Multiply! Total: 0   <td style="text-align: right;"><input style="width: 100px;" type="number" value="0" id="dividend">      <td style="text-align: right;"><input style="width: 100px;" type="number" value="0" id="divisor">   <td colspan="2" style="text-align:center; padding: 5px;"><button id="division-button" onClick="division;">Divide! Total: 0  '); } var calc = $('<li> Calculator</a></li>'); $(window.WikiaBar.wikiaBarWrapperObj.find('.tools')).append(calc); calc = $('#calculator'); calc.one('click', function (e) { e.stopPropagation; calc.click(function (e) {   e.stopPropagation;    calculator;  }); });