var punches, punchList, listLength, object; function isItArray(object) { console.log(`is ${object} Array = ${Array.isArray(object)}`); // return Array.isArray(object); } function putJson(data) { let req = new XMLHttpRequest(); req.onreadystatechange = () => { if (req.readyState == XMLHttpRequest.DONE) { document.getElementById("result").innerHTML = new Date().getTime() + " - " + req.status; getJson(genList); } }; req.open("PUT", jsonUrl, true); req.setRequestHeader("Content-type", "application/json"); req.send(data); } function getJson(callback) { displayMeta(); console.log(`getJson`); let req = new XMLHttpRequest(); req.onreadystatechange = () => { if (req.readyState == XMLHttpRequest.DONE) { window.punches = JSON.parse(req.responseText); window.punches.sort(function(a, b){return a.priority - b.priority}); callback(window.punches); } }; req.open("GET", jsonUrl, true); req.send(); } function genList(punchList) { document.getElementById("showDone").innerHTML = "Show Done: " + showDone + ""; disableElement("punchDetail"); enableElement("punchListAll"); var itemStyle = "punches"; isItArray(punchList); // punchList.sort(function(a, b){return new Date(a.date).getTime() - new Date(b.date).getTime()}); listLength = punchList.length; // list = "
Punch Item | Status | Priority | Action | "; //prioritize in-progress var list = ''; for (i = 0; i < listLength; i++) { if (punchList[i].progress.toLowerCase() === "in progress") { console.log(`in progress`); // list += "
---|