1
0

slack.min.js 873 B

12
  1. document.addEventListener("DOMContentLoaded",function(){startPolling()});var SLACK;function Slack(){this.lastServerVersion=0}Slack.prototype.update=function(b){b.v&&(this.lastServerVersion=b.v);b["static"]&&console.log("updated static");b.live&&console.log("updated LIVE")};SLACK=new Slack;var NEXT_RETRY=5;function poll(b){var a=new XMLHttpRequest;a.timeout=6E4;a.onreadystatechange=function(c){if(4===a.readyState)if(0===a.status)poll(b),NEXT_RETRY=5;else{c=null;var d=2===Math.floor(a.status/100);if(d){NEXT_RETRY=5;c=a.response;try{c=JSON.parse(c)}catch(e){c=null}}else NEXT_RETRY+=Math.floor(NEXT_RETRY/2),NEXT_RETRY=Math.min(60,NEXT_RETRY);b(d,c)}};a.open("GET","api?v="+SLACK.lastServerVersion,!0);a.send(null)}
  2. function onPollResponse(b,a){b?(a&&SLACK.update(a),startPolling()):setTimeout(startPolling,1E3*NEXT_RETRY)}function startPolling(){poll(onPollResponse)};