You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
759 B
JavaScript

async function autoUpdate(url, interval, callback = () => {}, method = 'post') {
await new Promise((resolve, reject) => {
$.ajax({
type: method,
url: url,
dataType: 'json',
success: function (data) {
callback(data)
resolve(data)
},
error: function (reason) {
setTimeout(() => autoUpdate(url, interval, callback, method), interval)
reject(reason)
}
})
})
setTimeout(() => autoUpdate(url, interval, callback, method), interval)
}
const INTERVAL = 30000
const LONG_INTERVAL = 600000
function getSC(input) {
return input.split(",").find(value => /^[Ss][Cc]/.test(value)) ?? input
}