I have been trying to make a chrome app that is completely filled by a textarea and I would like to make that textarea dynamically resize with the app window. I do not how ever want to use any external library for example jquery.
My html is:
<!DOCTYPE html>
<html>
<head>
<title>Plain Spellcheck</title>
<link rel="stylesheet" type="text/css" href="main.css">
<script type="text/javascript" src="main.js"></script>
</head>
<body>
<textarea id="textarea" spellcheck="true" class="textarea"></textarea>
</body>
</html>
I have not found any useful css so I will not post the practically empty stylesheet.
My nonfunctional and admittedly mangled code is:
function windowHeight(){
var mainWindow = chrome.app.window.get("mainWindow");
var height = mainWindow.innerBounds.height;
var textarea = document.getElementById("textarea");
var newHeight = parseInt(height);
var fixedHeight = newHeight * 0.04;
var height = newHeight - fixedHeight;
var height = height.toString();
textarea.style.height = height + "px";
}
document.addEventListener("DOMContentLoaded", function(){
var target = window.innerHeight;
var observer = new MutationObserver(function(mutations){
mutations.forEach(function(mutation){
chrome.app.window.onBoundsChanged.addListener(windowHeight());
});
});
var config = {attributes:false, childList:false, characterData:true};
observer.observe(target,config);
});