Created
July 19, 2012 09:16
-
-
Save josejuan/3142522 to your computer and use it in GitHub Desktop.
anonymousGridComputing.html
This file contains hidden or 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
<!DOCTYPE html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> | |
<title>Anonymous Grid Computing</title> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> | |
<script> | |
// se produce cuando un hilo a acumulado suficientes datos | |
function RegisterData(msg) { | |
// mostramos el resultado | |
$('#PiDigits').html( | |
// de enviar los datos | |
$.ajax({url: "/cgi-bin/agc.pl?" + msg.data.T + "," + msg.data.H, async: false}). | |
responseText.split("\n")[0] | |
); | |
} | |
// crea un nuevo hilo de trabajo | |
function LaunchBigJob() { | |
var w = new Worker("bigJob.js"); | |
w.onmessage = RegisterData; | |
// cada 5 segundos enviará los datos al servidor | |
w.postMessage(5000); | |
} | |
$(function() { | |
$('#Start').click(function() { | |
LaunchBigJob(); | |
var r = $('#Running'); | |
r.data('count', 1 + ~~r.data('count')); | |
r.html(r.data('count') + " running workers"); | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<div> | |
<span id="PiDigits" style="border-bottom: 1px solid black; font-size: 25px">...</span><br /> | |
<span id="Running" data-count="0">0 running workers</span><br /> | |
<input id="Start" type="button" value="Start worker" /> | |
</div> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment