mirror of
https://gitlab.com/Oreolek/salet-module.git
synced 2024-06-26 03:50:49 +03:00
Separated the supporting functions into a new file
This commit is contained in:
parent
5788fc9ffd
commit
dcec69177a
1
Cakefile
1
Cakefile
|
@ -3,6 +3,7 @@ fs = require 'fs'
|
|||
util = require 'util'
|
||||
sources = [
|
||||
'markdown.coffee'
|
||||
'utils.coffee'
|
||||
'view.coffee'
|
||||
'unit.coffee'
|
||||
'character.coffee'
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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 "<a href='#{ref}' class='way' id='waylink-#{ref}'>#{content}</a>"
|
||||
|
||||
Array::remove = (e) -> @[t..t] = [] if (t = @indexOf(e)) > -1
|
||||
|
||||
class SaletRoom
|
||||
constructor: (spec) ->
|
||||
@visited = 0
|
||||
|
|
|
@ -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).
|
||||
|
|
24
src/utils.coffee
Normal file
24
src/utils.coffee
Normal file
|
@ -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 "<a href='#{ref}' class='way' id='waylink-#{ref}'>#{content}</a>"
|
||||
|
||||
Array::remove = (e) -> @[t..t] = [] if (t = @indexOf(e)) > -1
|
||||
|
||||
addClass = (element, className) ->
|
||||
if (element.classList)
|
||||
element.classList.add(className)
|
||||
else
|
||||
element.className += ' ' + className
|
|
@ -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 "<a href='#{ref}' class='way'>#{content}</a>"
|
||||
|
||||
addClass = (element, className) ->
|
||||
if (element.classList)
|
||||
element.classList.add(className)
|
||||
else
|
||||
element.className += ' ' + className
|
||||
|
||||
class SaletView
|
||||
init: () =>
|
||||
jQuery("#page").on("click", "a", (event) ->
|
||||
|
|
Loading…
Reference in a new issue