Skip to content

Instantly share code, notes, and snippets.

@oshanz
Created June 23, 2014 03:59
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 oshanz/e9bdb0c4cfb5ac105734 to your computer and use it in GitHub Desktop.
Save oshanz/e9bdb0c4cfb5ac105734 to your computer and use it in GitHub Desktop.
observer
var worker = new Worker(URL + "view/gmapsRoute/js/observer.js");
worker.postMessage("sdfdf");
worker.onmessage = function(event) {
alert("Received message " + event.data);
worker.terminate();
};
*************************************************************************************
/**
* @author Waruna Oshan Wisumperuma
* @contact warunaoshan@gmail.com
*/
onmessage = function(event) {
postMessage(event.data);
setInterval(function getLatestGeo() {
postMessage('a');
// var xmlhttp = new XMLHttpRequest();
// xmlhttp.onreadystatechange = function() {
// if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
// console.log(xmlhttp.responseText);
// }
// };
// xmlhttp.open("GET", "latestGeo?lastGeoId=" + lastGeoId);
// xmlhttp.send();
}, 30000);
};
//importScripts("XMLHttpRequest.js");
//
//onmessage = function(event) {
// var xhr = creatXMLHTTPRequest();
// xhr.open('GET', 'widgets/widgetDefinition' + event.data + '.xml', true);
// xhr.send(null);
// xhr.onreadystatechange = function() {
// if (xhr.readyState == 4) {
// if (xhr.status == 200 || xhr.status ==0) {
// postMessage(xhr.responseText);
// } else {
// throw xhr.status + xhr.responseText;
// }
// }
// }
//}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment