Skip to content

Commit

Permalink
[NEW] autorefresh
Browse files Browse the repository at this point in the history
  • Loading branch information
monolithonadmin committed Jul 15, 2023
1 parent baa5351 commit 9958ea5
Showing 1 changed file with 32 additions and 23 deletions.
55 changes: 32 additions & 23 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,41 @@
</style>
</head>
<body>
<h1>Case List</h1>
<ul id="case-list"></ul>

<script>
// Fetch case data from the API
fetch('https://accountinghu.frappe.cloud/api/resource/Cases?filters=[["status", "=", "In progress"]]', {
headers: {
'Authorization': 'token 0a269f112eaa757:09b775a8259d857',
'Accept': 'application/json'
}
})
.then(response => response.json())
.then(data => {
const caseList = document.getElementById('case-list');
<script>
function fetchCases() {
fetch('https://accountinghu.frappe.cloud/api/resource/Cases?filters=[["status", "=", "In progress"]]', {
headers: {
'Authorization': 'token 0a269f112eaa757:09b775a8259d857',
'Accept': 'application/json'
}
})
.then(response => response.json())
.then(data => {
const caseList = document.getElementById('case-list');
caseList.innerHTML = ''; // Clear previous list

data.data.forEach(caseData => {
const li = document.createElement('li');
li.innerHTML = `
<span class="case-name">${caseData.name}</span> - ${caseData.subject}
`;
caseList.appendChild(li);
});
})
.catch(error => {
console.error('Error:', error);
});
</script>
data.data.forEach(caseData => {
const li = document.createElement('li');
li.innerHTML = `
<span class="case-name">${caseData.name}</span> - ${caseData.subject}
`;
caseList.appendChild(li);
});
})
.catch(error => {
console.error('Error:', error);
});
}

// Fetch cases initially
fetchCases();

// Refresh data every 3 seconds
setInterval(fetchCases, 3000);
</script>

</body>
</html>

0 comments on commit 9958ea5

Please sign in to comment.