Skip to content

Instantly share code, notes, and snippets.

@cnicodeme
Created October 15, 2015 09:36
Show Gist options
  • Save cnicodeme/34793dd18c65e3fa17da to your computer and use it in GitHub Desktop.
Save cnicodeme/34793dd18c65e3fa17da to your computer and use it in GitHub Desktop.
Check the availability of a specific server at OVH, and once it's available, alert the user (via "alert" to freeze the browser) and refresh the page
// https://eu.soyoustart.com/fr/commande/soYouStart.xml?reference=143sys10&quantity=1
function find(reference) {
jQuery.ajax({
'url': 'https://ws.ovh.com/dedicated/r2/ws.dispatcher/getAvailability2'
}).done(function (data) {
for (var i = 0; i < data.answer.availability.length; i++) {
if (data.answer.availability[i].reference !== reference) continue;
for (var y=0; y < data.answer.availability[i].zones.length; y++) {
var avail = data.answer.availability[i].zones[y].availability;
if (avail === 'unknown' || avail === 'unavailable') continue;
alert(reference + ' is available !');
window.location.href = 'https://eu.soyoustart.com/fr/commande/soYouStart.xml?reference=' + reference + '&quantity=1';
}
}
});
}
setInterval(function() {
find('143sys10');
}, (5 * 60 * 1000));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment