Created
January 22, 2013 04:52
-
-
Save carcruz/4592138 to your computer and use it in GitHub Desktop.
This is a simple calc project using OPFCLI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('lib/setup') | |
Spine = require('spine') | |
GeneralModal = require("modals/generalModal") | |
class App extends Spine.Controller | |
@extend Spine.Controller.ModalController | |
events: | |
"click .btn1" : "suma" | |
constructor: -> | |
super | |
@setupModal() | |
@html require("views/layout") | |
suma = (form) -> | |
a = eval_(form.a.value) | |
b = eval_(form.b.value) | |
c = a + b | |
form.ans.value = c | |
resta = (form) -> | |
a = eval_(form.a.value) | |
b = eval_(form.b.value) | |
c = a - b | |
form.ans.value = c | |
multiplica = (form) -> | |
a = eval_(form.a.value) | |
b = eval_(form.b.value) | |
c = a * b | |
form.ans.value = c | |
divide = (form) -> | |
a = eval_(form.a.value) | |
b = eval_(form.b.value) | |
c = a / b | |
form.ans.value = c | |
a_pow_b = (form) -> | |
a = eval_(form.a.value) | |
b = eval_(form.b.value) | |
c = Math.pow(a, b) | |
form.ans.value = c | |
module.exports = App |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="hero-unit"> | |
<form name="formx"> | |
<input type=text size=4 value=12 name="a"> | |
<input type="button" value=" + " onClick="suma(this.form)"> | |
<input type="button" value=" - " onClick="resta(this.form)"> | |
<input type="button" value=" x " onClick="multiplica(this.form)"> | |
<input type="button" value=" / " onClick="divide(this.form)"> | |
<input type="number" size=4 value=3 name="b"> = <input type "number" value=0 name="ans" size=9> | |
</form> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment