This file contains 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
Function.prototype.method = function(name, func) | |
{ | |
if (!this.prototype[name]) | |
{ | |
this.prototype[name] = func; | |
return this; | |
} | |
}; | |
Object.method('superior', function(name) |
This file contains 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
Animal = (function() | |
{ | |
function Animal(name) | |
{ | |
this.name = name; | |
} | |
Animal.prototype.move = function(meters) | |
{ | |
return alert(this.name + (" moved " + meters + "m.")); |
This file contains 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
__hasProp = {}.hasOwnProperty, | |
__extends = function(child, parent) | |
{ | |
for (var key in parent) | |
{ | |
if (__hasProp.call(parent, key)) | |
child[key] = parent[key]; | |
} | |
function ctor() |
This file contains 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
class Animal | |
constructor: (@name) -> | |
move: (meters) -> | |
alert @name + " moved #{meters}m." | |
class Snake extends Animal | |
move: -> | |
alert "Slithering..." | |
super 5 |
This file contains 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
class DecoderView extends Backbone.View | |
initialize: -> | |
@model.bind('parsedCharacter', @render) | |
render: (token) => | |
messageBox = $('#messageBox') | |
messageBox.val(messageBox.val() + token) |
This file contains 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
class MorseDecoder extends Backbone.Model | |
initializeKey: => | |
""" | |
Omitting code that initializes the morse code key | |
dictionary. | |
""" | |
initialize: => | |
@inputTokens = [] |
This file contains 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
class CommunicationLineView extends Backbone.View | |
initialize: -> | |
@model.bind('hasNewData', @render) | |
render: (tokens) => | |
context = document.getElementById( | |
"communicationLineCanvas").getContext('2d') | |
context.clearRect(0, 0, context.canvas.width, 29) | |
tokenNum = 0 |
This file contains 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
class CommunicationLine extends Backbone.Model | |
initialize: (options) => | |
@inputQueue = [] | |
@communicationLine = | |
['', '', '', '', '', '', '', '', '', ''] | |
@decoder = options.decoder | |
setInterval(@moveDataOneStep, 100) |
This file contains 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
class StraightKeyInput extends Backbone.View | |
initialize: -> | |
@dashTimer = null | |
@dashFlag = false | |
@wordStopTimer = null | |
@wordStopFlag = false | |
events: | |
'mousedown #straight-key': 'startTimers', |
This file contains 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
drawSignalLine = -> | |
context = document.getElementById( | |
"communicationLineCanvas").getContext('2d') | |
context.clearRect(0, 0, | |
context.canvas.width, context.canvas.height) | |
context.moveTo(0, 30) | |
context.lineTo(500, 30) | |
context.strokeStyle = "#000" |
NewerOlder