-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add: options page to store user email
- Loading branch information
Showing
4 changed files
with
95 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Lfx-Post Options</title> | ||
<link href="style.css" type="text/css" rel="stylesheet"> | ||
</head> | ||
<body class="optionsPage"> | ||
<section class="userInfo"> | ||
<span>Your email address: </span> | ||
<input id="userEmail" type="email" placeholder="[email protected]" required> | ||
<div id="status"></div> | ||
<button id="save">Save</button> | ||
</section> | ||
<iframe style="margin: 105px auto 0; display: block;" width="420" height="315" src="https://www.youtube.com/embed/AjPau5QYtYs" frameborder="0" allowfullscreen></iframe> | ||
<script src="options.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Saves options to chrome.storage | ||
function save_options() { | ||
var email = document.getElementById('userEmail').value; | ||
chrome.storage.sync.set({ | ||
user: email, | ||
}, function () { | ||
// Update status to let user know options were saved. | ||
var status = document.getElementById('status'); | ||
status.textContent = 'Options saved.'; | ||
setTimeout(function () { | ||
status.textContent = ''; | ||
}, 750); | ||
}); | ||
} | ||
|
||
// Restores the preferences stored in chrome.storage. | ||
function restore_options() { | ||
// Use default value user = ''. | ||
chrome.storage.sync.get({ | ||
user: '', | ||
}, function (items) { | ||
document.getElementById('userEmail').value = items.user; | ||
}); | ||
} | ||
document.addEventListener('DOMContentLoaded', restore_options); | ||
document.getElementById('save').addEventListener('click', | ||
save_options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters