function notepadPreview() {
  notepadClearPreview()
  var content = document.getElementById('pagecontent').value
  var request = new XMLHttpRequest();
  request.onreadystatechange = function() {
    if (request.readyState == XMLHttpRequest.DONE && request.status == 200) {
      document.getElementById('preview').innerHTML = request.responseText;
    }
  };
  request.open('POST', '/notes/preview');
  request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  var params = new URLSearchParams()
  params.append('pagecontent', content)
  request.send(params.toString());
}

function notepadClearPreview() {
  document.getElementById('preview').innerHTML = '';
}
