Skip to content

Instantly share code, notes, and snippets.

@schoeffman
Created April 2, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schoeffman/b43f6fb040b55b46bbde to your computer and use it in GitHub Desktop.
Save schoeffman/b43f6fb040b55b46bbde to your computer and use it in GitHub Desktop.
Domino's and Slack
(function () {
var prevState = null;
function notify(state)
{
var n = new XMLHttpRequest();
n.open("POST", "https://slack.com/api/chat.postMessage?token=TOKEN-HERE&channel=%23test&text=" + state + "&username=Domino's%20Notify&icon_url=http%3A%2F%2Fcdn.marketplaceimages.windowsphone.com%2Fv8%2Fimages%2F81c41161-1148-4f50-bdda-dd681d2a4b1d%3FimageType%3Dws_icon_large&pretty=1");
n.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
n.send();
}
setInterval(function () {
var state = document.getElementById('intl-tracker').getAttribute('data-currentstage');
if (state != prevState) {
prevState = state;
if(state == "1") {
message = "Order%20Placed";
} else if(state == "2") {
message = "Prep";
} else if(state == "3") {
message = "Bake";
} else if(state == "4") {
message = "Quality%20Check";
} else if(state == "5") {
message = "%20Out%20for%20Delivery";
} else {
message = "Unknown%20State";
}
notify(message);
}
}, 5000);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment