summaryrefslogtreecommitdiffstats
path: root/src/memory.js
blob: 336716a45a723c9b19134430da1466ee01d4d493 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
SVG.extend(SVG.Element, {
   // Initialize local memory object
  _memory: {}

  // Remember arbitrary data
, remember: function(k, v) {
    /* remember every item in an object individually */
    if (typeof arguments[0] == 'object')
      for (var v in k)
        this.remember(v, k[v])

    /* retrieve memory */
    else if (arguments.length == 1)
      return this._memory[k]

    /* store memory */
    else
      this._memory[k] = v

    return this
  }

  // Erase a given memory
, forget: function() {
    if (arguments.length == 0)
      this._memory = {}
    else
      for (var i = arguments.length - 1; i >= 0; i--)
        delete this._memory[arguments[i]]

    return this
  }

})