Clean up HTML code

This commit is contained in:
Han Dai 2020-03-30 12:46:03 -04:00
parent b40eb40f8d
commit 357871793c
2 changed files with 22 additions and 22 deletions

View File

@ -6,16 +6,16 @@
<body> <body>
<h2>Settings</h2> <h2>Settings</h2>
<form id="settings" method="post"> <form id="settings" method="post">
<label for="fname">Purdue Login: </label><br> Purdue Login:<br>
<input type="text" id="alias" name="alias" placeholder="pete123">@purdue.edu<br> <input type="text" name="alias" placeholder="pete123">@purdue.edu<br>
<label for="lname">BoilerKey PIN:</label><br> BoilerKey PIN:<br>
<input type="password" id="pin" name="pin" placeholder="1234"><br> <input type="password" name="pin" placeholder="1234"><br>
<label for="lname">Duo Mobile Activation Code: (e.g. if your Duo Activation URL is https://m-1b9bef70.duosecurity.com/activate/<strong>LoR3mIP5um</strong>, then the code will be <strong>LoR3mIP5um</strong>).</label><br> Duo Mobile Activation Code: (e.g. if your Duo Activation URL is https://m-1b9bef70.duosecurity.com/activate/<strong>LoR3mIP5um</strong>, then the code will be <strong>LoR3mIP5um</strong>).<br>
<input type="text" id="activationCode" name="activationCode" placeholder="LoR3mIP5um"><br> <input type="text" name="activationCode" placeholder="LoR3mIP5um"><br>
<label for="lname">HOTP Secret:</label><br> HOTP Secret:<br>
<input type="text" id="key" name="key" placeholder="Leave it blank" disabled><br> <input type="text" name="key" placeholder="Leave it blank" disabled><br>
<label for="lname">HOTP Counter:</label><br> HOTP Counter:<br>
<input type="text" id="counter" name="counter" placeholder="Leave it blank" disabled><br><br> <input type="text" name="counter" placeholder="Leave it blank" disabled><br><br>
<input type="submit" value="submit"> <input type="submit" value="submit">
</form> </form>
<br><hr> <br><hr>

View File

@ -3,23 +3,23 @@ window.onload=function(){
var form = document.getElementById('settings'); var form = document.getElementById('settings');
form.addEventListener("submit", processForm); form.addEventListener("submit", processForm);
chrome.storage.sync.get(["alias", "pin", "activationCode", "key", "counter"], function(result) { chrome.storage.sync.get(["alias", "pin", "activationCode", "key", "counter"], function(result) {
if(result.alias) document.getElementById("alias").value = result.alias; if(result.alias) document.getElementsByName("alias")[0].value = result.alias;
if(result.pin) document.getElementById("pin").value = result.pin; if(result.pin) document.getElementsByName("pin")[0].value = result.pin;
if(result.activationCode) document.getElementById("activationCode").value = activationCode = result.activationCode; if(result.activationCode) document.getElementsByName("activationCode")[0].value = activationCode = result.activationCode;
if(result.key) document.getElementById("key").value = result.key; if(result.key) document.getElementsByName("key")[0].value = result.key;
if(result.counter) document.getElementById("counter").value = result.counter; if(result.counter) document.getElementsByName("counter")[0].value = result.counter;
}); });
function processForm(e) { function processForm(e) {
e.preventDefault(); e.preventDefault();
chrome.storage.sync.set({ "alias": document.getElementById("alias").value, chrome.storage.sync.set({ "alias": document.getElementsByName("alias")[0].value,
"pin": document.getElementById("pin").value, "pin": document.getElementsByName("pin")[0].value,
"activationCode": document.getElementById("activationCode").value, "activationCode": document.getElementsByName("activationCode")[0].value,
"key": document.getElementById("key").value, "key": document.getElementsByName("key")[0].value,
"counter": document.getElementById("counter").value "counter": document.getElementsByName("counter")[0].value
}, function() { }, function() {
if(activationCode != document.getElementById("activationCode").value){ if(activationCode != document.getElementsByName("activationCode")[0].value){
activateDuoMobile(document.getElementById("activationCode").value); activateDuoMobile(document.getElementsByName("activationCode")[0].value);
}else{ }else{
alert("SAVED!"); alert("SAVED!");
} }