Source: site.view [edit]
Function name: wordGameScoreLine
Arguments: chapter,section,name,inp,ans,img,num,right,numTried,rnd,cmd
Description:
Page type: webl
Render function:   wordGameRender
Module: noahGames

Page source:

var html = "";
var file = Wub_ReplaceAll(Wub_ReplaceAll(ans, " ", ""), "-", "") + ".wav";
file = Wub_ReplaceAll(file, "'", "");
file = Wub_ReplaceAll(file, "`", "");
file = Wub_ReplaceAll(file, "^", "");
file = Wub_ReplaceAll(file, "-", "");
file = Wub_ReplaceAll(file, "?", "");

var n = WubCall("noahGames.lastRnd", []);
if (ToInt(Str_Trim(rnd)) member n) then
   html = `Hey now, no cheating...<p><a href="/webl/WubHub_DoIt?cmdline=wordGame:` + name + `">Start Again</a>`;
else

     var funcinfo = Wub_GetFunctionInfo("noahGames.lastRnd");
     var lastRnds = WubEval(funcinfo.exec) ? [];
     funcinfo.exec := ToString(lastRnds + [ToInt(Str_Trim(rnd))]);
     Wub_SaveFunctionInfo(funcinfo);

// remove any interior spaces
inp = Wub_ReplaceAll(inp, "  ", " ");
ans = Wub_ReplaceAll(ans, "  ", " ");

if Str_ToLowerCase(Str_Trim(inp)) == Str_ToLowerCase(Str_Trim(ans)) then
   html = "<h2>Right!!!</h2>\n<h3>" + ans + "</h3>\n";
   right = ToInt(right) + 1;
   numTried = ToInt(numTried) + 1
else
   if cmd == "Skip" then
      html = "The answer is <b>" + ans + "</b>.<p>";
   else
      html = "No, it's <b>" + ans + "</b><p>      (you said <i>" + inp + "</i>)<p>";
      numTried = ToInt(numTried) + 1
   end
end;

/*
html = html + `<script>function EvalSound(soundobj) { var thissound=document.getElementById(soundobj);  thissound.Play(); } </script>` + "\n";
html = html + `<embed src="http://a1852.phobos.apple.com/us/r1000/117/Music/72/28/8d/mzi.rjwrbxee.aac.p.m4a" height="45" id="wordaudio" width="170" type="application/x-mplayer2" autostart="1" loop="0"></embed>` + "\n";
*/

// "http://gamesbynoah.com/sounds/` + file + `" height="45" id="wordaudio" width="170" type="application/x-mplayer2" autostart="1" loop="0"
// </embed>` + "\n";

html = html + `<form> <input type="button" value="Play Again" onClick="EvalSound('wordaudio')"> </form>` + "\n";

num = ToInt(num) + 1;

html = html + Markup(WubCall("wordGameTestLine", [chapter, section, name, num, right, numTried]));

end;

NewPiece(html, "text/html");