#32 added basic settings for #11

This commit is contained in:
kaffem 2020-08-05 07:12:04 +02:00
parent f95cec8999
commit c6df27e818
2 changed files with 47 additions and 0 deletions

View file

@ -0,0 +1,22 @@
<!DOCTYPE html>
<html>
<head>
<title>Enhanced Aniwatch Settings</title>
<meta charset="utf-8">
<head>
<body>
<form>
<h4>Enhanced Aniwatch Settings</h4>
<label>Maximum Player Width <input type="number" id="maxPlayerWidth" min="1920" max="20000" value="1920" style="width: 75px; text-align:right;">
<span style="margin-left:-82px; font-size:12px;">px:</label>
<br>
<label>Actual Player Width <input type="number" id="actualPlayerWidth" min="1370" max="10000" value="1370" style="width: 75px; text-align:right;">
<span style="margin-left:-82px; font-size:12px;">px:</label>
<br>
<button id="save">Save</button>
</form>
<script src="settings.js"></script>
</body>
</html>

View file

@ -0,0 +1,25 @@
// Saves settings to chrome.storage
function save_settings() {
let items = {
maxPlayerWidth: document.getElementById('maxPlayerWidth').value,
actualPlayerWidth: document.getElementById('actualPlayerWidth').value
};
chrome.storage.local.set(items, function() {
alert('Settings saved.');
});
}
// Restores the settings using stored in chrome.storage
function restore_settings() {
chrome.storage.local.get([
'maxPlayerWidth',
'actualPlayerWidth'
], function(r) {
document.getElementById('maxPlayerWidth').value = r.maxPlayerWidth;
document.getElementById('actualPlayerWidth').value = r.actualPlayerWidth;
});
}
document.getElementById('save').addEventListener('click', save_settings);
document.addEventListener('DOMContentLoaded', restore_settings);