<commit_before>function mhnChartingMain()
{
  var div = document.createElement('div');
  var body = document.getElementsByTagName('body')[0];

  // stubbed, for now.
  var name = "fred";
  var key = "fredhasakeyhonestthisistotallylegit";

  div.style.height =          '300px';
  div.style.width =           '760px';
  div.style.marginLeft =      '-380px';   // offset the width for centering.
  div.style.position =        'fixed';
  div.style.backgroundColor = '#aaaaaa';  // grey
  div.style.zIndex =          '1337';     // on top of other DIVs
  div.style.top =             '0';        // at top of the screen
  div.style.left =            '50%';      // centered
  div.style.align =           'left';     // inner elements LHS aligned

  div.innerHTML =
    "<p align=\"left\">" +
    "<form action=\"http://charting.mhnltd.co.uk/notes\" method=\"post\">" +

    "<input type=\"hidden\" name=\"notes[user]\" value=\"" + name + "\" />" +

    "<input type=\"hidden\" name=\"notes[key]\" value=\"" + key + "\" />" +

    "<input type=\"hidden\" name=\"notes[location]\" value=\"" +
    document.location.href + "\" />" +

    "<input type=\"hidden\" name=\"notes[doctype]\" value=\"webpage\" />" +

    "<label for=\"notes[title]\">Title: </label>" +
    "<input type=\"text\" name=\"notes[title]\" value=\"" +
    document.title +
    "\"/><br />" +

    "<label for=\"notes[body]\">Body: </label>" +
    "<textarea name=\"notes[body]\" rows=\"10\" cols=\"80\"></textarea><br />" +

    "<label for=\"notes[goals][]\">Goal: </label>" +
    "<select name=\"notes[goals][]\">" +
    "<option value=\"1\">One</option>" +
    "<option value=\"2\">Two</option>" +
    "<option value=\"3\">Three</option>" +
    "</select><br />" +
    
    "</form></p>"

  body.appendChild(div);
}<commit_msg>updated to start populating goals + actually submit form.<commit_after>function mhnChartingMain()
{
  var serverLocation = "http://dev.mhnltd.co.uk:3000";
  var div = document.createElement('div');
  var body = document.getElementsByTagName('body')[0];

  var goals = getGoals();

  // stubbed, for now.
  var name = "fred";
  //var key = "";

  setForm(div, serverLocation, name, goals);

  formBodyField = div.getElementsByTagName('textarea')[0];
  formBodyField.value = "yatta yatta";

  body.appendChild(div);
}

/*
 * Retrieves the goals for this user, as an array of indexed strings.
 */
function getGoals()
{
  return [["0","jhdsahj"], ["1", "kjsdfi"], ["2", "qweur"]];
}


/**
 * Initialise form for div.
 */
function setForm(div, serverLocation, name, goals)
{
  div.style.height =          '300px';
  div.style.width =           '760px';
  div.style.marginLeft =      '-380px';   // offset the width for centering.
  div.style.position =        'fixed';
  div.style.backgroundColor = '#aaaaaa';  // grey
  div.style.zIndex =          '1337';     // on top of other DIVs
  div.style.top =             '0';        // at top of the screen
  div.style.left =            '50%';      // centered
  div.style.align =           'left';     // inner elements LHS aligned
  div.innerHTML =
    "<p align=\"left\">" +
    "<form action=\"" + serverLocation + "/notes\" method=\"post\">" +

    "<input type=\"hidden\" name=\"user[name]\" value=\"" + name + "\" />" +

    //"<input type=\"hidden\" name=\"notes[key]\" value=\"" + key + "\" />" +

    "<input type=\"hidden\" name=\"source[location]\" value=\"" +
    document.location.href + "\" />" +

    "<input type=\"hidden\" name=\"source[doctype]\" value=\"webpage\" />" +

    "<label for=\"notes[title]\">Title: </label>" +
    "<input type=\"text\" name=\"source[title]\" value=\"" +
    document.title +
    "\"/><br />" +

    "<label for=\"notes[body]\">Body: </label>" +
    "<textarea name=\"notes[body]\" rows=\"10\" cols=\"80\"></textarea><br />" +

    getGoalSelect(goals) + "<br />" +

    "<input type=\"submit\" value=\"Submit\">" + 
    
    "</form></p>"
}

function getGoalSelect(goals)
{
    var goalSelect = 
    "<label for=\"notes[goals][]\">Goal: </label>" +
    "<select name=\"notes[goals][]\">";
    for (var i = 0; i < goals.length; i++)
    {
      goalSelect += 
        "<option value=\"" + goals[i][0] + "\">" + goals[i][1] + "</option>";
    }
    goalSelect += "</select>";
    return goalSelect;
}

function getSelText()
{
  var selectedText = "";
  if (window.getSelection)
  {
    selectedText = window.getSelection();
  }
  else if (document.getSelection)
  {
    selectedText = document.getSelection();
  }
  else if (document.selection)
  {
    selectedText = document.selection.createRange().text;
  }

  return selectedText;
}
{'fraction_non_alphanumeric': 0.22075389948006932, 'fraction_numerical': 0.012131715771230503, 'mean_word_length': 2.6297169811320753, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 56, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2606916', 'n_tokens_mistral': 1576, 'n_tokens_neox': 1542, 'n_words': 313}