Browse Source

Clean up HTML code

master
Han Dai 2 years ago
parent
commit
357871793c
  1. 20
      options.html
  2. 24
      options.js

20
options.html

@ -6,16 +6,16 @@
<body>
<h2>Settings</h2>
<form id="settings" method="post">
<label for="fname">Purdue Login: </label><br>
<input type="text" id="alias" name="alias" placeholder="pete123">@purdue.edu<br>
<label for="lname">BoilerKey PIN:</label><br>
<input type="password" id="pin" 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>
<input type="text" id="activationCode" name="activationCode" placeholder="LoR3mIP5um"><br>
<label for="lname">HOTP Secret:</label><br>
<input type="text" id="key" name="key" placeholder="Leave it blank" disabled><br>
<label for="lname">HOTP Counter:</label><br>
<input type="text" id="counter" name="counter" placeholder="Leave it blank" disabled><br><br>
Purdue Login:<br>
<input type="text" name="alias" placeholder="pete123">@purdue.edu<br>
BoilerKey PIN:<br>
<input type="password" name="pin" placeholder="1234"><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" name="activationCode" placeholder="LoR3mIP5um"><br>
HOTP Secret:<br>
<input type="text" name="key" placeholder="Leave it blank" disabled><br>
HOTP Counter:<br>
<input type="text" name="counter" placeholder="Leave it blank" disabled><br><br>
<input type="submit" value="submit">
</form>
<br><hr>

24
options.js

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

Loading…
Cancel
Save