Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove jquery from options #246

Merged
merged 14 commits into from
Oct 30, 2019
9 changes: 4 additions & 5 deletions app/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<html>
<head>
<link href="styles/options.css" rel="stylesheet">
<script src="bower_components/jQuery/dist/jquery.js"></script>
<script src="scripts/options.js"></script>
</head>
<body>
Expand All @@ -13,10 +12,10 @@ <h1 class="title">Do Not Merge WIP for GitHub</h1>
<div class="content">
<form action="" class="options">
<div class="option">
<label for="protected_branch">Protected Branch <span class="weak">(Regular Expression)</span></label>
<input type="text" id="protected_branch" name="protected_branch" placeholder="e.g. deployment/*" /><br />
<label for="button_message">Button Message <span class="weak">(String)</span></label>
<input type="text" id="button_message" name="button_message" placeholder="WIP! You can't merge!" />
<label for="protectedBranch">Protected Branch <span class="weak">(Regular Expression)</span></label>
<input type="text" id="protectedBranch" name="protectedBranch" placeholder="e.g. deployment/*" /><br />
<label for="buttonMessage">Button Message <span class="weak">(String)</span></label>
<input type="text" id="buttonMessage" name="buttonMessage" placeholder="WIP! You can't merge!" />
</div>
<div class="buttons">
<button id="save_btn" class="button">Save</button>
Expand Down
18 changes: 9 additions & 9 deletions app/scripts/options.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
'use strict';
(() => {
'use strict';

(function($){
$(function(){
$('#protected_branch').val(localStorage.protectedBranch);
$('#button_message').val(localStorage.buttonMessage);
window.addEventListener('DOMContentLoaded', () => {
document.getElementById('protectedBranch').value = localStorage.protectedBranch;
document.getElementById('buttonMessage').value = localStorage.buttonMessage;

$('#save_btn').closest('form').submit(function(e) {
document.getElementById('save_btn').closest('form').addEventListener('submit', e => {
e.preventDefault();
localStorage.protectedBranch = $('#protected_branch').val();
localStorage.buttonMessage = $('#button_message').val();
localStorage.protectedBranch = e.target.protectedBranch.value;
localStorage.buttonMessage = e.target.buttonMessage.value;

window.alert('The options have been saved!');
});
});
})(jQuery);
})();