Wonder what have I won:
Album:
https://www.allmusic.com/album/mag-earwhig!-mw0000019690
Review:
https://www.allmusic.com/album/mag-earwhig!-mw0000019690/reviewAjax
User review:
https://www.allmusic.com/album/mag-earwhig!-mw0000019690/userReviewsAjax
function onStateChange(timer, resolve, reject, func = null) {
if (this !== null && timer !== null) { // this is xmlhttp bound
if (this.readyState === 4) {
clearTimeout(timer); timer = null;
if (this.status === 200) {
if (func) {return func(this.responseText);}
else {resolve(this.responseText);}
} else {
if (!func) {reject({status: this.status, responseText: this.responseText});}
}
}
} else if (!func) {reject({status: 408, responseText: this.responseText})}; // 408 Request Timeout
return null;
}
// May be used to async run a func for the response or as promise
function send({method = 'GET', URL, body = void(0), func = null, requestHeader = [/*[header, type]*/], bypassCache = false}) {
const p = new Promise((resolve, reject) => {
let timer = null;
const xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
// https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest#bypassing_the_cache
// Add ('&' + new Date().getTime()) to URLS to avoid caching
xmlhttp.open(
method,
URL + (bypassCache
? (/\?/.test(URL) ? '&' : '?') + new Date().getTime()
: '')
);
requestHeader.forEach((pair) => {
if (!pair[0] || !pair[1]) {console.log('HTTP Headers missing: ' + pair); return;}
xmlhttp.setRequestHeader(...pair);
});
if (bypassCache) {
xmlhttp.setRequestHeader('Cache-Control', 'private');
xmlhttp.setRequestHeader('Pragma', 'no-cache');
}
timer = setTimeout((xmlhttp) => {
xmlhttp.abort();
timer = null;
if (!func) { // 408 Request Timeout
let status = 408;
try {status = xmlhttp.status;} catch(e) {}
reject({status, responseText: 'Request Timeout'});
}
}, 30000, xmlhttp);
xmlhttp.onreadystatechange = onStateChange.bind(xmlhttp, timer, resolve, reject, func);
xmlhttp.send(method === 'POST' ? body : void(0));
});
return p;
}
send({method: 'GET', URL: "https://www.allmusic.com/album/mag-earwhig!-mw0000019690/reviewAjax", func: fb.ShowPopupMessage.bind(fb)});