/*  worker.js  */

function onMsg(e){
	if(e.data == 'kill'){
		postMessage('Shutting down.');
		close();
	} else {
		var input = JSON.parse(e.data);
		evaluate(input);
	}
}

function evaluate(i){
	if(i.a > i.b){
		postMessage(i.a + ' is greater than ' + i.b);
	} else if(i.a < i.b){
		postMessage(i.a + ' is less than ' + i.b);
	} else if(i.a == i.b) {
		postMessage(i.a + ' is equal to ' + i.b);
	} else this.postMessage('Not sure what happened.');
}

addEventListener('message', onMsg, false);