Skip to content

Commit

Permalink
tidy up script.js
Browse files Browse the repository at this point in the history
  • Loading branch information
pfedan committed Aug 26, 2019
1 parent 8551e8e commit e9703dd
Showing 1 changed file with 16 additions and 20 deletions.
36 changes: 16 additions & 20 deletions src/app/static/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@ var currentState = '';
var lastCountdownStart = 0;
var tCal = 0;

xmlhttp.onreadystatechange = getNewImageList;
xmlhttp.open("GET", "../images", true);
xmlhttp.send();

autoRefresh();

// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];
span.onclick = function () {
modal.style.display = "none";
}
modal.onclick = function () {
modal.style.display = "none";
}

document.addEventListener("keypress", function onEvent(event) {
if (event.key == "s") {
Expand Down Expand Up @@ -49,8 +63,8 @@ function showCountDown() {
divCD.style.display = "block";
setTimeout(function () { showCountdownNumber(3) }, 1000);
setTimeout(function () { showCountdownNumber(2) }, 2000);
setTimeout(function () { showCountdownNumber(1) }, 3000),
setTimeout(function () { showCountdownNumber("Smile!") }, 4000);
setTimeout(function () { showCountdownNumber(1) }, 3000);
setTimeout(function () { showCountdownNumber("Smile!") }, 4000);
setTimeout(function () { loadXMLDoc("../doPhoto", function () { }) }, 4000 - tCal);
setTimeout(function () { divCD.style.display = "none" }, 5000);
}
Expand All @@ -76,8 +90,6 @@ function loadXMLDoc(url, cfunc) {
xmlhttpRefresh.send();
}

xmlhttp.onreadystatechange = getNewImageList;

function getNewImageList() {
if (this.readyState == 4 && this.status == 200) {
var res = JSON.parse(this.responseText);
Expand All @@ -89,9 +101,6 @@ function getNewImageList() {
}
}

xmlhttp.open("GET", "../images", true);
xmlhttp.send();

function makeImageView(list) {
//document.getElementById("gallery").innerHTML = '';
var i;
Expand Down Expand Up @@ -119,8 +128,6 @@ function makeImageView(list) {
cntPhotos = list.length;
}

autoRefresh();

function autoRefresh() {
console.log("called autoRefresh")
var target = document.getElementById('json');
Expand All @@ -138,16 +145,5 @@ function autoRefresh() {
};
});
}


setInterval(doRefresh, 350);
}

// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];
span.onclick = function () {
modal.style.display = "none";
}
modal.onclick = function () {
modal.style.display = "none";
}

0 comments on commit e9703dd

Please sign in to comment.