Skip to content

Instantly share code, notes, and snippets.

@vhark
Forked from edwardrf/test.html
Created August 23, 2013 14:36
Show Gist options
  • Save vhark/6319993 to your computer and use it in GitHub Desktop.
Save vhark/6319993 to your computer and use it in GitHub Desktop.
<html>
<head><title>Test Ajax</title>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script>
$(function(){
$('.run').click(function(){
var buf = [
['0','0','0','0','0','0','0','0'],
['0','0','0','0','0','0','0','0'],
['0','0','0','0','0','0','0','0'],
['0','0','0','0','0','0','0','0'],
['0','0','0','0','0','0','0','0'],
['0','0','0','0','0','0','0','0'],
['0','0','0','0','0','0','0','0'],
['0','0','0','0','0','0','0','0']
];
var aqiSH = (35);
if(aqiSH <=38)
{
buf[0][7] = 'A';
}
if(aqiSH >38 && aqiSH<=75)
{
buf[1][7] = 'A';
}
if(aqiSH >75 && aqiSH<=113)
{
buf[2][7] = 'A';
}
if(aqiSH >113 && aqiSH<=150)
{
buf[3][7] = 'A';
}
if(aqiSH >150 && aqiSH<=188)
{
buf[4][7] = 'A';
}
if(aqiSH >188 && aqiSH<=225)
{
buf[5][7] = 'A';
}
if(aqiSH >225 && aqiSH<=263)
{
buf[6][7] = 'A';
}
if(aqiSH >263 && aqiSH<=300)
{
buf[7][7] = 'A';
}
if(aqiSH >300)
{
buf[7][7] = 'A';
}
}
moveLeft(buf, pmToGrid)
$.get("http://10.0.10.89:3000/?cmd=" + toString(buf), function(data){
console.log(data);
});
});
});
function toString(b){
var result = '';
for(var i = 0; i < 8; i++){
for(var j = 0; j < 8; j++){
result = result + b[i][j];
console.log('i=', i, 'j=', j, 'result=', result);
}
}
return result;
}
//move left and update last column with row data
function moveLeft(b, aqiSH){
for(var i = 0; i < 8; i++){
for(var j = 0; j < 7; j++){
b[i][j] = b[i][j+1];
}
}
for(var i = 0; i < 8; i++){
for(var j = 0; j < 7; j++){
b[i][j] = aqiSH;
}
}
}
</script>
</head>
<a href="javascript:void(0)" class="run">Run</a>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment