Created
April 2, 2015 14:11
-
-
Save schoeffman/b43f6fb040b55b46bbde to your computer and use it in GitHub Desktop.
Domino's and Slack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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