| 15 | |
| 16 | // Public methods |
| 17 | public run(): void{ |
| 18 | // We copy the render link so we can use it in the functions below |
| 19 | var renderLink: RenderLinkInput = this; |
| 20 | |
| 21 | // We set the change event |
| 22 | $(this.element).change(function(event){ |
| 23 | // We check if the new value correspond to the answer (if it does we fire the callbacks) |
| 24 | if(renderLink.enigmaAnswer.isRight($(this).val())) |
| 25 | renderLink.callbackCollection.fire(); |
| 26 | // Here it means that the new value doesn't correspond to the answers |
| 27 | else if(renderLink.callbackCollectionWrong != null){ |
| 28 | renderLink.callbackCollectionWrong.fire(); |
| 29 | } |
| 30 | |
| 31 | // We empty the input area |
| 32 | $(this).val(""); |
| 33 | |
| 34 | return false; // Avoid event bubbling |
| 35 | }); |
| 36 | |
| 37 | // We set the focus |
| 38 | $(this.element).focus(); |
| 39 | } |
| 40 | } |