Collaborama About Help Contact Anonymous [login] Source: site.view [edit] Function name: wordGameTestLine Arguments: chapter,section,name,num,right,numTried Description: Page type: webl Render function: wordGameRender Module: noahGames Page source: var html = ""; var lines = wubvars.gameLines ? []; var per = 100; numTried = ToInt(numTried); var score = ToInt(right) * 100; if (numTried > 1) then per = ToInt(right) * 100 / (numTried - 1); end; if (num > Size(lines)) then html = "<p>Good work, " + Str_ToUpperCase(name) + ", you finished with a score of " + ToString(score) + " points for this section!<p>"; var peopleScores = WubCall("wordGameScores", []) ? [. .]; var scores = peopleScores[name] ? [. .]; var high = ToInt(scores[chapter + section].high) ? 0; if score > high then high = score; scores[ chapter + section] := [. high=score, max=ToInt(num-1)*100 .]; peopleScores[name] := scores; var funcinfo = Wub_GetFunctionInfo("wordGameScores"); funcinfo.exec := ToString(peopleScores); Wub_SaveFunctionInfo(funcinfo); end; html = html + "Your high score is: " + ToString(high) + " points.<p>"; html = html + `<a href="/webl/WubHub_DoIt?cmdline=wordGame:` + name + `">Start Over</a>`; else var line = Str_Trim(lines[num-1]); var data = Str_Split(line, ","); var imgLeft = ""; var imgRight = ""; var i = Str_IndexOf("img(", data[0]); if i >= 0 then imgLeft = Select(data[0], i+4, Size(data[0])); data = [Select(data[0], 0, i), data[1]]; i = Str_IndexOf(")", imgLeft); imgLeft = Select(imgLeft, 0, i) end; i = Str_IndexOf("img(", data[1]); if i >= 0 then imgRight = Select(data[1], i+4, Size(data[1])); data = [data[0], Select(data[1], 0, i)]; i = Str_IndexOf(")", imgRight); imgRight = Select(imgRight, 0, i) end; var inp = Str_Trim(data[0]); var rnd = Wub_RandomInt(100000); html = html + "<p>You're on: " + ToString(num) + " / " + ToString(Size(lines)) + " <br> Points: " + ToString(score) + "</p><hr>\n"; if (inp != "") then html = html + "<H1>" + inp + "</H1>\n"; end; if (imgLeft != "") then html = html + `<img height=200 src="` + imgLeft + `"><p><p>` + "\n" end; html = html + `<form name="test" action="/webl/WubHub_DoIt" method="post">` + ` <input name="cmdline" value="wordGameScoreLine(chapter, section, name, inp, ans, img, num, right, numTried, rnd, cmd)" type="hidden"/> ` + ` <input name="chapter" value="` + chapter + `" type="hidden"/> ` + ` <input name="section" value="` + section + `" type="hidden"/> ` + ` <input name="name" value="` + name + `" type="hidden"/> ` + ` <input name="ans" value="` + data[1] + `" type="hidden"/> ` + ` <input name="img" value="` + imgRight + `" type="hidden"/> ` + ` <input name="num" value="` + ToString(num) + `" type="hidden"/> ` + ` <input name="right" value="` + ToString(right) + `" type="hidden"/> ` + ` <input name="rnd" value="` + ToString(rnd) + ` " type="hidden"/> ` + ` <input name="numTried" value="` + ToString(numTried) + `" type="hidden"/> ` + ` Your answer: <input name="inp" value="" size="45" title="Your answer" autocomplete="off" autocorrect="off" autocapitalize="off"/>` + ` <input name="cmd" type="submit" value="Enter"> ` + ` <input name="cmd" type="submit" value="Skip"> ` + `</form>`; end; NewPiece(html, "text/html");