var currently_dragging = null; // if this is null, we have nothing being dragged. if it's not null, then it will represent the glyph object (as goes in the glyphs array) which is currently being dragged
var major_radius;
const glyphs = [];
const vowels = [];
const consonants = [];
var svg;
var connections_container;
$(document).ready(function() {
svg = $('svg#arena')[0];
connections_container = $('svg#arena #connections');
major_radius = parseFloat($('circle').attr('r'));
$(document).on("mouseup", on_mouse_up);
$('td > svg').on("mousedown", function(event) {
let receptacle = $("#consonant_put_it_in_here");
let selected = $(this);
receptacle.html(selected.html());
const mouse_position = svg_from_dom({x:event.clientX, y:event.clientY}, svg);
var g = make_new_consonant();
set_location(g, mouse_position);
currently_dragging = g;
})
$('.vowel-example > svg').on("mousedown", function(event) {
let receptacle = $('#vowel_put_it_in_here');
let selected = $(this);
receptacle.html(selected.html());
var g = make_new_vowel();
const mouse_position = svg_from_dom({x:event.clientX, y:event.clientY}, svg);
set_location(g, mouse_position);
currently_dragging = g;
});
$('td > svg').each(function() { this.setAttribute('viewBox',"0 30 40 100");});
populate_consonant_grid();
populate_vowels();
});
function populate_consonant_grid() {
// this function expects that there's a #consonant-grid table, where each row corresponds to a glyph set
// the cells of the row need to be filled with the various possible configurations of that glyph
// so like, the
in a given row should contain a .megaglyph svg group, which contains the base glyph plus all possible radicals.
// then we use the split_megaglyph function to generate the five possible configurations out of that megaglyph
// and insert the five configured glyphs into their corresponding (td) cells of the table
$("#consonant-grid tbody tr").each(function (asdf, row) { // iterate over the rows in the table
// row will now be something like
// that is, a tr containing one th on either end plus a td for each consonant in this row
var head = $(row).find("th:first-child svg"); // this is the header for the row, which should contain the .megaglyph object
var megaglyph = head.find(".megaglyph");
var glyphs = split_megaglyph(megaglyph); // now this is a list of the configured consonant symbols
$(row).find("td").each(function(idx, cell) { // iterate over the cells in the row
// cell will now be a
cell which contains the IPA for that cell's consonants, plus the