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(); } }; req.open("PUT", jsonUrl, true); req.setRequestHeader("Content-type", "application/json"); req.send(data); } function getJson() { // var GoogleAuth = gapi.auth2.init(); // if (GoogleAuth.isSignedIn.get() === true) { //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); genStatuses(window.punches); } }; req.open("GET", jsonUrl, true); req.send(); // } else { // console.log('not logged in'); // } } function findArrayId(uid) { var length = window.punches.length; for (x = 0; x < length; x++) { if (window.punches[x].uuid === uid) { return x; } } } function tagFilter(tagItem) { console.log(`In tagFilter function`); window.tagFilterItem = tagItem; getJson(); } function clearTagFilter() { console.log(`Clear Tags`); window.tagFilterItem = undefined; getJson(); } function getStatus(punchList, statusFilter) { return punchList.filter(function(punch) { return punch.progress.toLowerCase() != statusFilter; }); } function genStatuses(punchList) { // genList(getStatus(punchList, "in progress"), "punchListInProgress"); // genList(getStatus(punchList, "new"), "punchListNew"); genList(getStatus(punchList, ""), "punchListBacklog"); } function genBacklog(punchList) { genList(punchList, "punchListBacklog"); } function genList(punchList, element) { 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; var list = '
subject: " + punchList[item].subject + "
Created: " + punchList[item].cDate + "
Modified Date: " + punchList[item].mDate + "
Priority: " + punchList[item].priority + "
Progress: " + punchList[item].progress + "