about summary refs log tree commit diff
path: root/web
diff options
context:
space:
mode:
authorsternenseemann <git@lukasepple.de>2017-08-31 00:50:12 +0200
committersternenseemann <git@lukasepple.de>2017-08-31 00:53:21 +0200
commit1232a51e39511a9e8be8fbf01eff98a7715cb151 (patch)
tree1914b6d367e31cb7c2a4b4d9a9f7d3674e95e55a /web
parentea085f55ec34b17b2b60207a28032f7b1630184c (diff)
Make Rational representation compatible with Haskell's ratio parsing
Diffstat (limited to 'web')
-rw-r--r--web/source/main.js18
1 files changed, 9 insertions, 9 deletions
diff --git a/web/source/main.js b/web/source/main.js
index 5e2654c..1ee25f1 100644
--- a/web/source/main.js
+++ b/web/source/main.js
@@ -63,8 +63,8 @@ class Music {
 
 class Rational {
     constructor(a, b) {
-        this.num = a;
-        this.den = b;
+        this.numerator = a;
+        this.denominator = b;
         this.reduce();
     }
 
@@ -78,17 +78,17 @@ class Rational {
             }
         };
 
-        var d = gcd(this.num, this.den);
-        this.num = div(this.num, d);
-        this.den = div(this.den, d);
+        var d = gcd(this.numerator, this.denominator);
+        this.numerator = div(this.numerator, d);
+        this.denominator = div(this.denominator, d);
     }
 
     toString() {
-        return `${this.num}/${this.den}`;
+        return `${this.numerator}/${this.denominator}`;
     }
 
     static fromObject(obj) {
-        return new Rational(obj.num, obj.den);
+        return new Rational(obj.numerator, obj.denominator);
     }
 }
 
@@ -185,8 +185,8 @@ function genericEditNode(data, callback) {
         var music = node.music;
         document.getElementById('pitch').value = music.pitch;
         document.getElementById('octave').value = music.octave;
-        document.getElementById('numerator').value = music.dur.num;
-        document.getElementById('denominator').value = music.dur.den;
+        document.getElementById('numerator').value = music.dur.numerator;
+        document.getElementById('denominator').value = music.dur.denominator;
     }
     document.getElementById('node-save').onclick = saveNode.bind(this, data, callback);
     document.getElementById('node-cancel').onclick = discardNode.bind(this, callback);