<commit_before>var ref = {
  'monday': getMonday(new Date()),
};

$('document').ready(function() {
  $('.stuff').hide();
  $('.mAll').hide();
  $('.navbar').hide();
  $.ajax({
    url: "/session",
    success: function(data) {
      if (data.username) {
        ref.user = data.username;
        $('.stuff').show();
        $('.navbar').show()
        $('.mAll').show();
        $('li#username').children('a').text(ref.user);
        $('.loggedIn').show();
        $('.loggedOut').hide();
        $('textarea').each(function(index, attribute) {
          $(this).removeAttr("disabled");
        });

        $.ajax({
          type: "GET",
          url: "/settings", 
          data: {
            'settings': ref.settings
          },
          statusCode: { 
            500: function() {
              alert("There's been a server error. Contact NLTL for assistance.");
            }
          },
          success: function(data) {
            console.log(data);
            ref.settings = data.settings;
            renderRows(ref.settings.rows);
          }
        });

      } else { // no one session for this browser found
        $('.choiceModal').modal({backdrop: 'static', 'keyboard': false});
        $('li#username').children('a').text('');
        $('.loggedIn').hide();
        $('.loggedOut').show();
        $('textarea').each(function(index, attribute) {
          $(this).attr("disabled", "");
        });
      }
    }
  });
  drawDates();

  $("#subjects").append('<div class="row"><div class="col-sm-2 col-sm-offset-10" id="year"></div></div>')


});

function saveWeek(o) {
  $.ajax({ // now get a new auth cookie from couch
    type: "POST",
    url: "/planner", 
    data: {
      'monday': ref.monday.toISOString().slice(0, 10),
      'data': JSON.stringify(o)
    },
    statusCode: {
      500: function() {
        alert("There's been a server error. Contact NLTL for assistance.");
      }
    },
    success: function(data) {

    }
  });
}

function getWeek(c) {
  $.ajax({
    type: "GET",
    url: "/planner",
    data: {
      monday: ref.monday.toISOString().slice(0, 10) 
    },
    statusCode: {
      404: function() { // if week doesn't exist
        c(genBlankAssignments());
      },
      500: function() {
        alert("There's been a server error. Contact NLTL for assistance.");
      }
    },
    success: function(data) {
      c(JSON.parse(data.assignments));
    }
  });
}

function getAssignmentValues() {
  var d = {};
  $('textarea').each(function (index, ta) {
    // with the cell's ID as the key, put the contents of the array, and the boolean of if it's completed or not, into the object.
    
    var code = '';
    if ($(this).css("background-color") != "rgb(255, 255, 255)") {
      for (var prop in ref.settings.colorCode) {
        if (ref.settings.colorCode.hasOwnProperty(prop)) {
          if (ref.settings.colorCode[prop] === $(this).css("background-color")) {
            code = prop;
            break;
          }
        }
      }
    }
    d[ta.id] = [ta.value, $(this).css("text-decoration") == "line-through", code]; 
  });
  return d;
}

function setAssignmentValues(d) {
  $('textarea').each(function (index, ta) {
    $(ta).css("text-decoration", "none solid rgb(0, 0, 0)");
    if (d[ta.id]) {
      $(ta).val(d[ta.id][0]);
      if (d[ta.id][1])
        $(ta).css("text-decoration", "line-through");
      if (d[ta.id][2])
        $(ta).css("background-color", ref.settings.colorCode[d[ta.id][2]]);
    }
    else
      $(ta).val('');
  });
}

function setSettings(s, callback) {
  $.ajax({
    type: "POST",
    url: "/settings", 
    data: {'settings': s},<commit_msg>fixed bug where cells would stay the sme color after week change<commit_after>var ref = {
  'monday': getMonday(new Date()),
};

$('document').ready(function() {
  $('.stuff').hide();
  $('.mAll').hide();
  $('.navbar').hide();
  $.ajax({
    url: "/session",
    success: function(data) {
      if (data.username) {
        ref.user = data.username;
        $('.stuff').show();
        $('.navbar').show()
        $('.mAll').show();
        $('li#username').children('a').text(ref.user);
        $('.loggedIn').show();
        $('.loggedOut').hide();
        $('textarea').each(function(index, attribute) {
          $(this).removeAttr("disabled");
        });

        $.ajax({
          type: "GET",
          url: "/settings", 
          data: {
            'settings': ref.settings
          },
          statusCode: { 
            500: function() {
              alert("There's been a server error. Contact NLTL for assistance.");
            }
          },
          success: function(data) {
            console.log(data);
            ref.settings = data.settings;
            renderRows(ref.settings.rows);
          }
        });

      } else { // no one session for this browser found
        $('.choiceModal').modal({backdrop: 'static', 'keyboard': false});
        $('li#username').children('a').text('');
        $('.loggedIn').hide();
        $('.loggedOut').show();
        $('textarea').each(function(index, attribute) {
          $(this).attr("disabled", "");
        });
      }
    }
  });
  drawDates();

  $("#subjects").append('<div class="row"><div class="col-sm-2 col-sm-offset-10" id="year"></div></div>')


});

function saveWeek(o) {
  $.ajax({ // now get a new auth cookie from couch
    type: "POST",
    url: "/planner", 
    data: {
      'monday': ref.monday.toISOString().slice(0, 10),
      'data': JSON.stringify(o)
    },
    statusCode: {
      500: function() {
        alert("There's been a server error. Contact NLTL for assistance.");
      }
    },
    success: function(data) {

    }
  });
}

function getWeek(c) {
  $.ajax({
    type: "GET",
    url: "/planner",
    data: {
      monday: ref.monday.toISOString().slice(0, 10) 
    },
    statusCode: {
      404: function() { // if week doesn't exist
        c(genBlankAssignments());
      },
      500: function() {
        alert("There's been a server error. Contact NLTL for assistance.");
      }
    },
    success: function(data) {
      c(JSON.parse(data.assignments));
    }
  });
}

function getAssignmentValues() {
  var d = {};
  $('textarea').each(function (index, ta) {
    // with the cell's ID as the key, put the contents of the array, and the boolean of if it's completed or not, into the object.
    
    var code = '';
    if ($(this).css("background-color") != "rgb(255, 255, 255)") {
      for (var prop in ref.settings.colorCode) {
        if (ref.settings.colorCode.hasOwnProperty(prop)) {
          if (ref.settings.colorCode[prop] === $(this).css("background-color")) {
            code = prop;
            break;
          }
        }
      }
    }
    d[ta.id] = [ta.value, $(this).css("text-decoration") == "line-through", code]; 
  });
  return d;
}

function setAssignmentValues(d) {
  $('textarea').each(function (index, ta) {
    $(ta).css("text-decoration", "none solid rgb(0, 0, 0)");
    if (d[ta.id]) {
      $(ta).val(d[ta.id][0]);
      if (d[ta.id][1])
        $(ta).css("text-decoration", "line-through");
      if (d[ta.id][2])
        $(ta).css("background-color", ref.settings.colorCode[d[ta.id][2]]);
      else {
        $(ta).css("background-color", "rgb(255, 255, 255)");
      }
    }
    else
      $(ta).val('');
  });
}

function setSettings(s, callback) {
  $.ajax({
    type: "POST",
    url: "/settings", 
    data: {'settings': s},
{'fraction_non_alphanumeric': 0.20424902514454754, 'fraction_numerical': 0.011160414145488773, 'mean_word_length': 2.1503600169419737, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '6160578', 'n_tokens_mistral': 2464, 'n_tokens_neox': 2353, 'n_words': 493}