mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-22 19:22:50 -06:00
Changes for publication of SALDO demo web apps
Published at http://spraakbanken.gu.se/swe/forskning/saldo/ordspel
This commit is contained in:
@@ -7,16 +7,22 @@
|
|||||||
<meta name = "viewport" content = "width = device-width">
|
<meta name = "viewport" content = "width = device-width">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body onload="start_saldotest()">
|
<body onload="start_saldotest();start_saldospel()">
|
||||||
<h1>En liten saldoleksak</h1>
|
|
||||||
|
<h2>Vilket ord ska bort?</h2>
|
||||||
|
<div id=saldospel>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h2>Hel- och halvspöke</h2>
|
||||||
<div id=saldotest>
|
<div id=saldotest>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
<small>
|
<small>
|
||||||
[Baserad på <a href="http://spraakbanken.gu.se/sal/ws/">SALDOs nättjänster</a>]
|
[Baserad på <a href="http://spraakbanken.gu.se/sal/ws/">SALDOs nättjänster</a>]
|
||||||
</small>
|
</small>
|
||||||
<small class=modtime>
|
<small class=modtime>
|
||||||
HTML <!-- hhmts start --> Last modified: Wed May 26 22:36:25 CEST 2010 <!-- hhmts end -->
|
HTML <!-- hhmts start --> Last modified: Thu May 27 14:02:42 CEST 2010 <!-- hhmts end -->
|
||||||
</small>
|
</small>
|
||||||
<address>TH <img src="http://www.altocumulus.org/~hallgren/online.cgi?icon" alt=""></address>
|
<address>TH <img src="http://www.altocumulus.org/~hallgren/online.cgi?icon" alt=""></address>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -19,13 +19,16 @@ function start_saldotest() {
|
|||||||
[button("Slumpa","random_word()"),
|
[button("Slumpa","random_word()"),
|
||||||
button("Rensa","clear_all()"),
|
button("Rensa","clear_all()"),
|
||||||
button("⌫","delete_last()"),
|
button("⌫","delete_last()"),
|
||||||
button("Ordlista","show_ordlista()"),
|
//button("Ordlista","show_ordlista()"),
|
||||||
button("Visa tänkbara drag","show_moves()"),
|
button("Visa tänkbara drag","show_moves()"),
|
||||||
button("Gör ett drag","make_a_move()"),
|
button("Gör ett drag","make_a_move()"),
|
||||||
button("Visa prefix","show_prefixes()"),
|
//button("Visa prefix","show_prefixes()"),
|
||||||
div_id("surface"),
|
div_id("surface"),
|
||||||
div_id("words"),
|
div_id("words"),
|
||||||
div_id("translations")])
|
div_id("translations")])
|
||||||
|
var style0="min-height: 3ex; margin: 5px; padding: 5px;";
|
||||||
|
element("surface").setAttribute("style",style0+"border: 3px dashed #e0e0e0;");
|
||||||
|
element("words").setAttribute("style",style0+"border: 3px solid #e0e0e0;");
|
||||||
clear_all();
|
clear_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,10 +77,11 @@ function get_completions() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function word(s) {
|
function word(s) {
|
||||||
var w=span_class("word",text(s));
|
//var w=span_class("word",text(s));
|
||||||
if(s==" ") w.innerHTML=" ";
|
//if(s==" ") w.innerHTML=" ";
|
||||||
w.setAttribute("onclick",'extend_current("'+s+'")');
|
//w.setAttribute("onclick",'extend_current("'+s+'")');
|
||||||
return w;
|
//return w;
|
||||||
|
return button(s,'extend_current("'+s+'")');
|
||||||
}
|
}
|
||||||
|
|
||||||
function extend_current(s) {
|
function extend_current(s) {
|
||||||
@@ -259,11 +263,15 @@ var spel={ antal_ord: 4, // antal närbesläktade ord att visa
|
|||||||
function start_saldospel() {
|
function start_saldospel() {
|
||||||
spel.hylla=div_id("hylla");
|
spel.hylla=div_id("hylla");
|
||||||
spel.status=div_id("status");
|
spel.status=div_id("status");
|
||||||
element("saldospel").innerHTML="<h2>Vilket ord ska bort? <span id=score></span></h2>";
|
//element("saldospel").innerHTML="<span id=score></span>";
|
||||||
appendChildren(element("saldospel"),
|
appendChildren(element("saldospel"),
|
||||||
[spel.hylla,spel.status,
|
[spel.hylla,spel.status,
|
||||||
button("Nya ord","spel0()")]);
|
p(text("")),
|
||||||
|
button("Nya ord","spel0()"),
|
||||||
|
text(" "),
|
||||||
|
wrap("b",span_id("score"))]);
|
||||||
spel.score=element("score");
|
spel.score=element("score");
|
||||||
|
show_score();
|
||||||
spel0();
|
spel0();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -306,7 +314,7 @@ function spel6(ordlista1,ord2) {
|
|||||||
var pos=Math.floor(Math.random()*spel.antal_ord);
|
var pos=Math.floor(Math.random()*spel.antal_ord);
|
||||||
var ordlista=shuffle(shuffle(ordlista1).slice(0,spel.antal_ord).concat(ord2));
|
var ordlista=shuffle(shuffle(ordlista1).slice(0,spel.antal_ord).concat(ord2));
|
||||||
spel.hylla.innerHTML="";
|
spel.hylla.innerHTML="";
|
||||||
var lista=empty_class("p","space");
|
var lista=empty_class("div","space");
|
||||||
for(var i=0;i<ordlista.length;i++)
|
for(var i=0;i<ordlista.length;i++)
|
||||||
lista.appendChild((button(ordlista[i],"spel7(this)")));
|
lista.appendChild((button(ordlista[i],"spel7(this)")));
|
||||||
spel.hylla.appendChild(lista);
|
spel.hylla.appendChild(lista);
|
||||||
@@ -315,11 +323,16 @@ function spel6(ordlista1,ord2) {
|
|||||||
function spel7(btn) {
|
function spel7(btn) {
|
||||||
btn.disabled=true;
|
btn.disabled=true;
|
||||||
var ok=btn.value==spel.ord2;
|
var ok=btn.value==spel.ord2;
|
||||||
btn.setAttribute("class",ok ? "correct" : "incorrect");
|
//btn.setAttribute("class",ok ? "correct" : "incorrect");
|
||||||
|
btn.setAttribute("style",ok ? "color: green" : "color: red");
|
||||||
if(ok) spel.antal_korrekta_svar++; else spel.antal_felaktiga_svar++;
|
if(ok) spel.antal_korrekta_svar++; else spel.antal_felaktiga_svar++;
|
||||||
|
show_score();
|
||||||
|
if(ok) spel0();
|
||||||
|
}
|
||||||
|
|
||||||
|
function show_score() {
|
||||||
spel.score.innerHTML=""+spel.antal_korrekta_svar+" rätt, "
|
spel.score.innerHTML=""+spel.antal_korrekta_svar+" rätt, "
|
||||||
+spel.antal_felaktiga_svar+" fel";
|
+spel.antal_felaktiga_svar+" fel";
|
||||||
if(ok) spel0();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function wf(ord) { // word form, wf("band..1") == "band"
|
function wf(ord) { // word form, wf("band..1") == "band"
|
||||||
|
|||||||
Reference in New Issue
Block a user