massi-world-scratch

a slew of pages that need no compilation
Log | Files | Refs

main.js (1274B)


      1 var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
      2     if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
      3         if (ar || !(i in from)) {
      4             if (!ar) ar = Array.prototype.slice.call(from, 0, i);
      5             ar[i] = from[i];
      6         }
      7     }
      8     return to.concat(ar || Array.prototype.slice.call(from));
      9 };
     10 var NOTES = ["A", "Bb", "B", "C", "Db", "D", "Eb", "E", "F", "Gb", "G", "Ab"];
     11 var QUALITIES = ["", "-", "°", "+"];
     12 var POSSIBILITIES = NOTES.reduce(function (accum, note) {
     13     return __spreadArray(__spreadArray([], accum, true), QUALITIES.map(function (q) { return note + q; }), true);
     14 }, []);
     15 var bag = new Array(POSSIBILITIES.length).fill(0).map(function (_, i) { return i; });
     16 var result = [];
     17 while (bag.length > 0) {
     18     var bagIdx = Math.floor(Math.random() * bag.length);
     19     var possibilitiesIdx = bag[bagIdx];
     20     result.push(POSSIBILITIES[possibilitiesIdx]);
     21     bag.splice(bagIdx, 1);
     22 }
     23 document.addEventListener("DOMContentLoaded", function () {
     24     document.getElementById("chart").innerHTML = result
     25         .map(function (note) { return "<code>".concat(note, "</code>"); })
     26         .join("");
     27 });
     28 // the other mode would be 1-7 in a given KEY, starting at a given INVERSION.