Skip to content

Instantly share code, notes, and snippets.

@orangkucing
Created September 27, 2012 21:36
Show Gist options
  • Save orangkucing/3796611 to your computer and use it in GitHub Desktop.
Save orangkucing/3796611 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="ja">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
</head>
<body>
<span id="span0"></span>
<form name="input" action="javascript:callback()">
↑ひらがなにしてください: <input type="text" size="20" />
<input type="submit" value="Submit" />
</form>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1");
dataSource = 'https://docs.google.com/spreadsheet/tq?key=0AiHytSptvOXddHJISzhSOXQ2RjkwZjVJN0JxYzc4cHc&headers=-1';
row = 0;
google.setOnLoadCallback(callback);
function callback() {
query = new google.visualization.Query(dataSource);
query.send(handleResponse);
}
function handleResponse(response) {
var data = response.getDataTable();
var s = '読みの練習<br />';
if (row != 0) {
s = 'まちがいです<br />';
if (document.input.elements[0].value == data.getFormattedValue(row, 1))
s = 'あたりです!<br />';
}
row = Math.floor(Math.random() * (data.getNumberOfRows() - 1)) + 1;
document.getElementById("span0").innerHTML = s + data.getFormattedValue(row, 2);
document.input.elements[0].value = '';
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment