local storage test

testing local storage usage

by Matt Rummler

HTML

<!DOCTYPE html>
<!--
All rights reserved Matthew Ernest Rummler 2008-2030.
-->
<body>
  body stuff
  <!--
  <input type="text" value="type the name here">
  -->
  <textarea placeholder="type over me" id="description" rows="5" columns="1"></textarea>
  <button id="saveText">
  I am a button
  Submit me!
  </button>
  <br>

  <div id="textDestination">
  The text will appear here
  </div>
  <!--
  <button id="loadText">
  Load the text into the text area
  </button>
  -->
</body>

CSS

body
{
	display: flex;
  flex-flow: column;
  justify-content: space-around;
}

JavaScript

/* 
 * All rights reserved Matthew Ernest Rummler 2008-2030.
 */
document.addEventListener
(
 "DOMContentLoaded"
 ,function()
 {
  //do all stuff here, same as jQuery's onReady but without the enormous library
  //events here
  var descriptionText = document.getElementById('description');
  var saveDataButton = document.getElementById('saveText');
  var targetText = document.getElementById('textDestination');
//  var loadDataButton = document.getElementById('loadText');
  // app Obj here
  var APP = 
  {
    savedData:'saveData'
    ,saveToLocal:function(targetElement)
    {
      localStorage.setItem(APP.savedData,targetElement.value);
      //alert('the APP.saveToLocal function has fired');
      return false;
    }
    ,loadFromLocal:function(targetElement2){targetElement2.innerHTML = localStorage.getItem(APP.savedData);}
  };
   //targetText.innerHTML = '';
  //descriptionText.innerHTML = targetText.innerHTML;
  descriptionText.oninput = function(){APP.saveToLocal(descriptionText);APP.loadFromLocal(targetText);};
  saveDataButton.onclick = function(){APP.saveToLocal(descriptionText);APP.loadFromLocal(targetText);};
//  loadDataButton.onclick = function(){APP.loadFromLocal(targetText)};  
 }
);
//this one has nothing to make the event fire... not sure what I was doing with this... but I think the local storage was not really the test... and that I have to finish the local storage part (or fish it out of the event creation...)