Skip to content

Commit

Permalink
Options alerts.
Browse files Browse the repository at this point in the history
  • Loading branch information
Yatskov committed Feb 14, 2020
1 parent d023bef commit f7e46c6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
17 changes: 17 additions & 0 deletions extension/options_page/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@
<script src="../assets/bootstrap-3.0.0/js/bootstrap.min.js"></script>
<script src="../scripts/Config.js"></script>
<script src="options_page.js"></script>
<style>
.alert {
padding: 20px;
color: white;
display: none;
margin-bottom: 15px;
}

#error {
background-color: #f44336;
}

#success {
background-color: #4CAF50;
}
</style>
</head>
<body>
<div class="container">
Expand Down Expand Up @@ -58,6 +74,7 @@ <h1>Web Scraper</h1>

<div class="form-group">
<div class="col-lg-offset-2 col-lg-10">
<div class="alert"></div>
<button type="submit" class="btn btn-default">Save</button>
</div>
</div>
Expand Down
14 changes: 13 additions & 1 deletion extension/options_page/options_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,19 @@ $(function () {
newConfig.restUrl = $("#restUrl").val();
}

config.updateConfiguration(newConfig);
config.updateConfiguration(newConfig, function(){
if (chrome.runtime.lastError){
$(".alert")
.attr("id", "error")
.text( "Failed to save options " + chrome.runtime.lastError.message)
.show();
} else{
$(".alert")
.attr("id", "success")
.text( "Options successfully updated." )
.show();
}
});
return false;
});
});

0 comments on commit f7e46c6

Please sign in to comment.