Im working on a custom stopwatch in JavaScript that will run offline. And trying to implement some basic settings that will be saved in HTML5 localStorage (or using default values if localStorage is not saved yet).
So I have settings.html window that will hold all the inputs:
<html>
<head>
<title>OS Stopky - Settings</title>
<link rel="stylesheet" type="text/css" href="osstopky.css">
<script type="text/javascript" src="settings.js"></script>
</head>
<body>
<div class="settingswrapper">
<br>
<table id="settingstable">
<tr>
<td>Counter font size</td>
<td><input type="text" id="settCounterSize" size="5" > [px]</td>
</tr>
</table>
</div>
<script>
Settings.load();
</script>
</body>
</html>
And in the settings.js I tried to create the object to hold the settings and work with them:
var Settings = {
settCounterSize: 66,
load: function() {
if (localStorage.settCounterSize) {
document.getElementById("settCounterSize").value = localStorage.settCounterSize;
} else {
document.getElementById("settCounterSize").value = this.settCounterSize;
}
},
save: function() {
localStorage.settCounterSize = document.getElementById("settCounterSize").value;
},
loadDefaults: function() {
}
};
However, once the settings.html page loads, the input field "settCounterSize" remains blank.
I think I need fresh pair of eyes for this, been stuck with this seemingly simple call for several hours, reading the W3 Schools and Javascript html call external object from external file I couldnt find where my problem lies..
Thank you for your time!