Add button to Gravity page

This makes sure that the user doesn't accidentally cause the lists
to update because they were curious and clicked the Update Lists
link on the sidebar. Also, they can update the lists multiple
times, if they so desire.
This commit is contained in:
Mcat12
2016-12-10 14:16:49 -05:00
parent 3c79f7c692
commit ff55cf085e
2 changed files with 11 additions and 6 deletions
+2 -1
View File
@@ -16,7 +16,8 @@
Success!
</div>
<pre id="output" style="width: 100%; height: 100%;"></pre>
<button class="btn btn-lg btn-primary btn-block" id="gravityBtn">Update Lists</button>
<pre id="output" style="width: 100%; height: 100%;" hidden="true"></pre>
<?php
require "footer.php";
+9 -5
View File
@@ -1,9 +1,11 @@
function eventsourcetest() {
function eventsource() {
var alInfo = $("#alInfo");
var alSuccess = $("#alSuccess");
var ta = document.getElementById("output");
var ta = $("#output");
var source = new EventSource("php/gravity.sh.php");
ta.html("");
ta.show();
alInfo.show();
alSuccess.hide();
@@ -13,7 +15,7 @@ function eventsourcetest() {
alSuccess.show();
}
ta.innerHTML += e.data;
ta.append(e.data);
}, false);
@@ -21,11 +23,13 @@ function eventsourcetest() {
source.addEventListener("error", function(e) {
alInfo.delay(1000).fadeOut(2000, function() { alInfo.hide(); });
source.close();
$("#gravityBtn").removeAttr("disabled");
}, false);
}
$(function(){
eventsourcetest();
$("#gravityBtn").on("click", () => {
$("#gravityBtn").attr("disabled", true);
eventsource();
});
// Handle hiding of alerts