Mercurial > js4py
annotate core-javascript/core-javascript-work/solution-2-d.js @ 150:5118d0e38ba4 core-javascript-latex
$ hg merge core-javascript # into core-javascript-latex
| author | jf3243 |
|---|---|
| date | Tue, 01 Nov 2011 08:58:38 +0000 |
| parents | 6c98b9680b2a |
| children | 9cdf095a283e |
| rev | line source |
|---|---|
|
146
6c98b9680b2a
Revisions to solution-2.rst and its solutiion-2-d.js component.
Jonathan Fine <jfine@pytex.org>
parents:
144
diff
changeset
|
1 // Rhino $ js -f library.js -f solution-2-d.js - |
|
6c98b9680b2a
Revisions to solution-2.rst and its solutiion-2-d.js component.
Jonathan Fine <jfine@pytex.org>
parents:
144
diff
changeset
|
2 |
| 108 | 3 var fields = {}; |
| 4 | |
| 5 fields.__init__ = function(keys){ | |
| 6 this.keys = keys; | |
| 7 }; | |
| 8 | |
| 9 fields.copy_attributes = function(src, tgt){ | |
|
146
6c98b9680b2a
Revisions to solution-2.rst and its solutiion-2-d.js component.
Jonathan Fine <jfine@pytex.org>
parents:
144
diff
changeset
|
10 |
| 108 | 11 var keys = this.keys; |
|
146
6c98b9680b2a
Revisions to solution-2.rst and its solutiion-2-d.js component.
Jonathan Fine <jfine@pytex.org>
parents:
144
diff
changeset
|
12 var key; |
| 108 | 13 var i; |
|
146
6c98b9680b2a
Revisions to solution-2.rst and its solutiion-2-d.js component.
Jonathan Fine <jfine@pytex.org>
parents:
144
diff
changeset
|
14 |
| 108 | 15 for(i=0; i< keys.length; i++){ |
|
146
6c98b9680b2a
Revisions to solution-2.rst and its solutiion-2-d.js component.
Jonathan Fine <jfine@pytex.org>
parents:
144
diff
changeset
|
16 key = keys[i]; |
|
6c98b9680b2a
Revisions to solution-2.rst and its solutiion-2-d.js component.
Jonathan Fine <jfine@pytex.org>
parents:
144
diff
changeset
|
17 tgt[key] = src['get_' + key](); |
| 108 | 18 }; |
| 19 }; | |
| 20 | |
|
146
6c98b9680b2a
Revisions to solution-2.rst and its solutiion-2-d.js component.
Jonathan Fine <jfine@pytex.org>
parents:
144
diff
changeset
|
21 var Fields = SimpleClass(fields); |
| 108 | 22 |
| 23 |
