diff --git a/Cakefile b/Cakefile index d21619b..f4bee5c 100644 --- a/Cakefile +++ b/Cakefile @@ -3,6 +3,7 @@ fs = require 'fs' util = require 'util' sources = [ 'markdown.coffee' + 'utils.coffee' 'view.coffee' 'unit.coffee' 'character.coffee' diff --git a/package.json b/package.json index e79c0fe..d8b69ce 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salet", - "version": "1.4.8", + "version": "1.4.9", "description": "A general client-side framework for cybertext interactive fiction games.", "keywords": ["ifiction", "interactive fiction", "games", "coffee-script", "text", "menu"], "homepage": "http://salet.oreolek.ru", diff --git a/src/room.coffee b/src/room.coffee index a854848..afdb859 100644 --- a/src/room.coffee +++ b/src/room.coffee @@ -1,16 +1,3 @@ -assert = (msg, assertion) -> console.assert assertion, msg - -Function.prototype.fcall = Function.prototype.call -Boolean.prototype.fcall = () -> - return this.valueOf() -String.prototype.fcall = () -> - return this.toString() - -way_to = (content, ref) -> - return "#{content}" - -Array::remove = (e) -> @[t..t] = [] if (t = @indexOf(e)) > -1 - class SaletRoom constructor: (spec) -> @visited = 0 diff --git a/src/salet.coffee b/src/salet.coffee index 3fdd86d..2f03ff4 100644 --- a/src/salet.coffee +++ b/src/salet.coffee @@ -1,17 +1,3 @@ -### -fcall() (by analogy with fmap) is added to the prototypes of both String and -Function. When called on a Function, it's an alias for Function#call(); -when called on a String, it only returns the string itself, discarding any input. -### - -Function.prototype.fcall = Function.prototype.call -Boolean.prototype.fcall = () -> - return this -String.prototype.fcall = () -> - return this - -assert = (assertion, msg) -> console.assert assertion, msg - ### This is the control structure, it has minimal amount of data and this data is volatile anyway (as in, it won't get saved). diff --git a/src/utils.coffee b/src/utils.coffee new file mode 100644 index 0000000..f6a24ee --- /dev/null +++ b/src/utils.coffee @@ -0,0 +1,24 @@ +### +fcall() (by analogy with fmap) is added to the prototypes of both String and +Function. When called on a Function, it's an alias for Function#call(); +when called on a String, it only returns the string itself, discarding any input. +### + +Function.prototype.fcall = Function.prototype.call +Boolean.prototype.fcall = () -> + return this +String.prototype.fcall = () -> + return this + +assert = (assertion, msg) -> console.assert assertion, msg + +way_to = (content, ref) -> + return "#{content}" + +Array::remove = (e) -> @[t..t] = [] if (t = @indexOf(e)) > -1 + +addClass = (element, className) -> + if (element.classList) + element.classList.add(className) + else + element.className += ' ' + className diff --git a/src/view.coffee b/src/view.coffee index 9145222..8cf496f 100644 --- a/src/view.coffee +++ b/src/view.coffee @@ -12,17 +12,6 @@ but they could be something else entirely. (That's why IDs are hardcoded.) There is only one instance of this class, and it's stored as `salet.view`. ### -assert = (msg, assertion) -> console.assert assertion, msg - -way_to = (content, ref) -> - return "#{content}" - -addClass = (element, className) -> - if (element.classList) - element.classList.add(className) - else - element.className += ' ' + className - class SaletView init: () => jQuery("#page").on("click", "a", (event) ->