Объединить два скрипта

Помогите объединить два скрипта

  1. checkbox переключает input disabled / enabled
  2. сохраняет статус checkbox после обновления страницы

После обновления страницы input неактивный, с галочкой checkbox Спасибо!

<script> //enabled disadled
$("#chk").attr('checked', !$("#disabledInput")[0].disabled);
$("#chk").click(function(){   
    $("#disabledInput").attr('disabled', !this.checked)
});
</script>

<script> //сохранение статуса чекбокса
var checkboxValues = JSON.parse(localStorage.getItem('checkboxValues')) || {},
    $checkboxes = $("#checkbox-container :checkbox");

$checkboxes.on("change", function(){
  $checkboxes.each(function(){
    checkboxValues[this.id] = this.checked;
  });
  
  localStorage.setItem("checkboxValues", JSON.stringify(checkboxValues));
});

// On page load
$.each(checkboxValues, function(key, value) {
  $("#" + key).prop('checked', value);
});
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.2/jquery.min.js" type="text/javascript"></script>

<div id="checkbox-container">
    <input type="checkbox" id="chk" /> 
    <input class=" span3" id="disabledInput" disabled type="text" />
</div>


Ответы (0 шт):