<html>
<head>
<meta charset="UTF-8">
<title>Canvas HTML Element Probability Board Game Tutorial ... RJM Programming ... July 2014 ... thanks to http://stackoverflow.com/questions/9880279/how-do-i-add-a-simple-onclick-event-handler-to-a-canvas-element</title>
<script language="JavaScript">
// Thanks to http://www.mathsisfun.com/data/probability.html
var sentenceparts = new Array(
"Choosing a nominated card from a deck", "involves 1 chance for 52 choices", "has a probability of " + eval(1.0 / 52.0),
"Choosing a card suit from a deck", "involves 13 chances for 52 choices", "has a probability of " + eval(1.0 / 4.0),
"Choosing a King from a card deck", "involves 4 chances for 52 choices", "has a probability of " + eval(1.0 / 13.0),
"Choosing a Picture card (K,Q,J) from a card deck", "involves 4x3 chances for 52 choices", "has a probability of " + eval(3.0 / 13.0),
"Choosing a red number card from a card deck", "involves 9x2 chances for 52 choices", "has a probability of " + eval(9.0 / 26.0),
"Rolling 5 with one die", "involves 1 chance for 6 choices", "has a probability of " + eval(1.0 / 6.0),
"Rolling 12 with two dice", "involves 1 chance for 6x6 choices", "has a probability of " + eval(1.0 / 36.0),
"Rolling 11 with two dice", "involves 2 chances for 6x6 choices", "has a probability of " + eval(1.0 / 18.0),
"Rolling 7 with two dice", "involves 6 chances for 6x6 choices", "has a probability of " + eval(1.0 / 6.0),
"Picking a prime number in counting numbers from 1 to 9", "involves 4 chances for 9 choices", "has a probability of " + eval(4.0 / 9.0),
"Picking a square number in counting numbers from 1 to 9", "involves 3 chances for 9 choices", "has a probability of " + eval(1.0 / 3.0),
"Picking a prime number in counting numbers from 1 to 99", "involves 25 chances for 99 choices", "has a probability of " + eval(25.0 / 99.0),
"Picking a square number in counting numbers from 1 to 99", "involves 9 chances for 99 choices", "has a probability of " + eval(1.0 / 11.0),
"Picking a cube number in counting numbers from 1 to 99", "involves 4 chances for 99 choices", "has a probability of " + eval(4.0 / 99.0),
"Picking a perfect number in counting numbers from 1 to 99", "involves 2 chances for 99 choices", "has a probability of " + eval(2.0 / 99.0),
"Picking a nonhypotenuse number in counting numbers from 1 to 99", "involves 58 chances for 99 choices", "has a probability of " + eval(58.0 / 99.0),
"Succeeding with first go at card game memories", "involves 3 chances for 51 choices", "has a probability of " + eval(1.0 / 17.0),
"Making pontoon with first card of Picture card (K,Q,J) or 10", "involves 4 chances for 51 choices", "has a probability of " + eval(4.0 / 51.0)
);
var ppl = 0;
var oklist = ":";
var pseudo_sentence = "";
var real_sentence = "";
var twothings = ["", ""];
var cderived_sentences = "";
var derived_sentences = [];
var prefix = [""];
var midbit= [];
var midlist = ":";
var suffix = [];
var cprefix = "";
var cmidbit = "";
var csuffix = "";
var ij, jk, kl, bword="", unknownselect = "<select id='unknown'></select>";
var score = 0.0;
var goes = 0.0;
var realgoes = 0;
var maxx = 0.0;
var maxy = 0.0;
var sentencepick = 0;
var threepick = 0;
var offx = 0.0;
var offy = 0.0;
var okay = 1;
var gpx = 30;
var gpy = 30;
var gpttext = "";
var cf = "18px Verdana";
function updatescore() {
var sis=document.getElementById('score');
sis.innerHTML = "Score is " + score.toString() + " from " + goes.toString() + " goes<a target=_blank href='http://www.mathsisfun.com/data/probability.html' title='Probability ideas ... thanks'>.</a>";
}
function onloading() {
ppl = 0;
oklist = ":";
pseudo_sentence = "";
real_sentence = "";
twothings = ["", ""];
cderived_sentences = "";
derived_sentences = [];
prefix = [];
midbit= [];
midlist = ":";
suffix = [];
cprefix = "";
cmidbit = "";
csuffix = "";
bword="";
unknownselect = "<select id='unknown'></select>";
for (ij=0; ij<sentenceparts.length; ij+=3) {
sentenceparts[eval(ij + 0)] = sentenceparts[eval(ij + 0)].replace("⁻", "⁻").replace("₀", "₀").replace("₀", "₀").replace("₁", "₁").replace("₁", "₁").replace("₂", "₂").replace("₂", "₂").replace("₃", "₃").replace("₃", "₃").replace("₄", "₄").replace("₄", "₄").replace("₅", "₅").replace("₅", "₅").replace("₆", "₆").replace("₆", "₆").replace("₇", "₇").replace("₇", "₇").replace("₈", "₈").replace("₈", "₈").replace("₉", "₉").replace("₉", "₉");
sentenceparts[eval(ij + 1)] = sentenceparts[eval(ij + 1)].replace("⁻", "⁻").replace("₀", "₀").replace("₀", "₀").replace("₁", "₁").replace("₁", "₁").replace("₂", "₂").replace("₂", "₂").replace("₃", "₃").replace("₃", "₃").replace("₄", "₄").replace("₄", "₄").replace("₅", "₅").replace("₅", "₅").replace("₆", "₆").replace("₆", "₆").replace("₇", "₇").replace("₇", "₇").replace("₈", "₈").replace("₈", "₈").replace("₉", "₉").replace("₉", "₉");
sentenceparts[eval(ij + 2)] = sentenceparts[eval(ij + 2)].replace("⁻", "⁻").replace("₀", "₀").replace("₀", "₀").replace("₁", "₁").replace("₁", "₁").replace("₂", "₂").replace("₂", "₂").replace("₃", "₃").replace("₃", "₃").replace("₄", "₄").replace("₄", "₄").replace("₅", "₅").replace("₅", "₅").replace("₆", "₆").replace("₆", "₆").replace("₇", "₇").replace("₇", "₇").replace("₈", "₈").replace("₈", "₈").replace("₉", "₉").replace("₉", "₉");
//alert(sentenceparts[eval(ij + 0)] + sentenceparts[eval(ij + 1)] + sentenceparts[eval(ij + 2)]);
if (sentenceparts[eval(ij + 1)].indexOf("[") > -1) {
prefix[prefix.length] = sentenceparts[eval(ij + 0)].replace("⁻", "⁻").replace("₀", "₀").replace("₀", "₀").replace("₁", "₁").replace("₁", "₁").replace("₂", "₂").replace("₂", "₂").replace("₃", "₃").replace("₃", "₃").replace("₄", "₄").replace("₄", "₄").replace("₅", "₅").replace("₅", "₅").replace("₆", "₆").replace("₆", "₆").replace("₇", "₇").replace("₇", "₇").replace("₈", "₈").replace("₈", "₈").replace("₉", "₉").replace("₉", "₉");
jk = sentenceparts[eval(ij + 1)].indexOf("[");
kl = sentenceparts[eval(ij + 1)].indexOf("]");
bword = sentenceparts[eval(ij + 1)].substring((jk + 1), eval((jk + 1) + kl - jk - 1));
//alert(bword);
sentenceparts[eval(ij + 1)] = sentenceparts[eval(ij + 1)].replace(" [" + bword + "]", "");
if (sentenceparts[eval(ij + 1)].indexOf("/") > -1) {
two_things = sentenceparts[eval(ij + 1)].split("/");
if (midlist.indexOf(":" + two_things[0] + ":") == -1) {
midlist = midlist + two_things[0] + ":";
midbit.push(two_things[0]);
}
derived_sentences[derived_sentences.length] = sentenceparts[eval(ij + 0)] + " " + two_things[0] + " " + sentenceparts[eval(ij + 2)];
if (midlist.indexOf(":" + two_things[1] + ":") == -1) {
midlist = midlist + two_things[1] + ":";
midbit.push(two_things[1]);
}
csuffix = csuffix + sentenceparts[eval(ij + 2)] + "`";
csuffix = csuffix + sentenceparts[eval(ij + 2)].replace(bword + " ", "") + "`";
suffix = csuffix.split("`");
derived_sentences[derived_sentences.length] = sentenceparts[eval(ij + 0)] + " " + two_things[1] + " " + sentenceparts[eval(ij + 2)];
derived_sentences[derived_sentences.length] = sentenceparts[eval(ij + 0)] + " " + sentenceparts[eval(ij + 2)].replace(bword + " ", "");
} else {
csuffix = csuffix + sentenceparts[eval(ij + 2)] + "`";
csuffix = csuffix + sentenceparts[eval(ij + 2)].replace(bword + " ", "") + "`";
suffix = csuffix.split("`");
derived_sentences[derived_sentences.length] = sentenceparts[eval(ij + 0)] + " " + sentenceparts[eval(ij + 1)] + " " + sentenceparts[eval(ij + 2)];
derived_sentences[derived_sentences.length] = sentenceparts[eval(ij + 0)].replace("⁻", "⁻").replace("₀", "₀").replace("₀", "₀").replace("₁", "₁").replace("₁", "₁").replace("₂", "₂").replace("₂", "₂").replace("₃", "₃").replace("₃", "₃").replace("₄", "₄").replace("₄", "₄").replace("₅", "₅").replace("₅", "₅").replace("₆", "₆").replace("₆", "₆").replace("₇", "₇").replace("₇", "₇").replace("₈", "₈").replace("₈", "₈").replace("₉", "₉").replace("₉", "₉") + " " + sentenceparts[eval(ij + 2)].replace(bword + " ", "");
}
} else if (sentenceparts[eval(ij + 1)].indexOf("/") > -1) {
prefix[prefix.length] = sentenceparts[eval(ij + 0)].replace("⁻", "⁻").replace("₀", "₀").replace("₀", "₀").replace("₁", "₁").replace("₁", "₁").replace("₂", "₂").replace("₂", "₂").replace("₃", "₃").replace("₃", "₃").replace("₄", "₄").replace("₄", "₄").replace("₅", "₅").replace("₅", "₅").replace("₆", "₆").replace("₆", "₆").replace("₇", "₇").replace("₇", "₇").replace("₈", "₈").replace("₈", "₈").replace("₉", "₉").replace("₉", "₉");
two_things = sentenceparts[eval(ij + 1)].split("/");
if (midlist.indexOf(":" + two_things[0] + ":") == -1) {
midlist = midlist + two_things[0] + ":";
midbit.push(two_things[0]);
}
csuffix = csuffix + sentenceparts[eval(ij + 2)] + "`";
suffix = csuffix.split("`");
//alert(99);
derived_sentences.push(sentenceparts[eval(ij + 0)] + " " + two_things[0] + " " + sentenceparts[eval(ij + 2)]);
//alert("... " + derived_sentences[derived_sentences.length - 1]);
if (midlist.indexOf(":" + two_things[1] + ":") == -1) {
midlist = midlist + two_things[1] + ":";
midbit.push(two_things[1]);
}
derived_sentences[derived_sentences.length] = sentenceparts[eval(ij + 0)].replace("⁻", "⁻").replace("₀", "₀").replace("₀", "₀").replace("₁", "₁").replace("₁", "₁").replace("₂", "₂").replace("₂", "₂").replace("₃", "₃").replace("₃", "₃").replace("₄", "₄").replace("₄", "₄").replace("₅", "₅").replace("₅", "₅").replace("₆", "₆").replace("₆", "₆").replace("₇", "₇").replace("₇", "₇").replace("₈", "₈").replace("₈", "₈").replace("₉", "₉").replace("₉", "₉") + " " + two_things[1] + " " + sentenceparts[eval(ij + 2)];
//alert(midlist + " ... " + derived_sentences[derived_sentences.length - 1]);
} else {
//alert(sentenceparts[eval(ij + 0)]);
prefix[prefix.length] = sentenceparts[eval(ij + 0)].replace("⁻", "⁻").replace("₀", "₀").replace("₀", "₀").replace("₁", "₁").replace("₁", "₁").replace("₂", "₂").replace("₂", "₂").replace("₃", "₃").replace("₃", "₃").replace("₄", "₄").replace("₄", "₄").replace("₅", "₅").replace("₅", "₅").replace("₆", "₆").replace("₆", "₆").replace("₇", "₇").replace("₇", "₇").replace("₈", "₈").replace("₈", "₈").replace("₉", "₉").replace("₉", "₉");
csuffix = csuffix + sentenceparts[eval(ij + 2)] + "`";
suffix = csuffix.split("`");
if (midlist.indexOf(":" + sentenceparts[eval(ij + 1)] + ":") == -1) {
midlist = midlist + sentenceparts[eval(ij + 1)] + ":";
midbit.push(sentenceparts[eval(ij + 1)]);
}
derived_sentences[derived_sentences.length] = sentenceparts[eval(ij + 0)].replace("⁻", "⁻").replace("₀", "₀").replace("₀", "₀").replace("₁", "₁").replace("₁", "₁").replace("₂", "₂").replace("₂", "₂").replace("₃", "₃").replace("₃", "₃").replace("₄", "₄").replace("₄", "₄").replace("₅", "₅").replace("₅", "₅").replace("₆", "₆").replace("₆", "₆").replace("₇", "₇").replace("₇", "₇").replace("₈", "₈").replace("₈", "₈").replace("₉", "₉").replace("₉", "₉") + " " + sentenceparts[eval(ij + 1)] + " " + sentenceparts[eval(ij + 2)];
}
}
kl = 0;
for (ij=0; ij<prefix.length; ij++) {
if (prefix[ij] != "") {
prefix[kl] = prefix[ij];
kl = kl + 1;
}
}
kl = 0;
cprefix = "<select id='sfirst' style='display:none; text-align:right;'>";
for (ij=0; ij<prefix.length; ij++) {
if (prefix[ij] != "") {
cprefix = cprefix + "<option value=" + kl + ">" + prefix[ij] + "</option>";
kl = kl + 1;
}
}
prefix[prefix.length] = "";
ppl = kl;
cprefix = cprefix + "<option value=" + kl + "></option>";
cprefix = cprefix + "</select>";
kl = 0;
cmidbit = "<select id='smiddle' style='display:none; text-align:center;'>";
for (ij=0; ij<midbit.length; ij++) {
cmidbit = cmidbit + "<option value=" + kl + ">" + midbit[ij] + "</option>";
kl = kl + 1;
}
cmidbit = cmidbit + "</select>";
kl = 0;
csuffix = "<select id='slast' style='display:none;'>";
for (ij=0; ij<suffix.length; ij++) {
if (suffix[ij] != "") {
csuffix = csuffix + "<option value=" + kl + ">" + suffix[ij] + "</option>";
kl = kl + 1;
}
}
csuffix = csuffix + "</select>";
kl = 0;
cderived_sentences = "<select id='sentences' style='display:none;'>";
for (ij=0; ij<derived_sentences.length; ij++) {
cderived_sentences = cderived_sentences + "<option value=" + kl + ">" + derived_sentences[ij] + "</option>";
kl = kl + 1;
}
cderived_sentences = cderived_sentences + "</select>";
//alert(cprefix);
//alert(cmidbit);
//alert(csuffix);
//alert(cderived_sentences);
document.getElementById('dsentence').innerHTML = document.getElementById('dsentence').innerHTML + cprefix;
document.getElementById('dsentence').innerHTML = document.getElementById('dsentence').innerHTML + cmidbit;
document.getElementById('dsentence').innerHTML = document.getElementById('dsentence').innerHTML + csuffix;
document.getElementById('dsentence').innerHTML = document.getElementById('dsentence').innerHTML + cderived_sentences;
pick_a_sentence();
elem.click();
}
function andthen() {
elem.click();
}
function check_answer(osel) {
if (osel.value != "") {
//alert(oklist);
goes = goes + 1;
if (oklist.indexOf(":" + osel.value + ":") == -1) {
updatescore();
placerealtext();
//window.open(url, "_blank"); //, "top=400,left=500,height=380,width=680");
setTimeout(andthen, 9000);
} else {
score = score + 1;
updatescore();
real_sentence = "Yay!!!";
placerealtext();
//window.open(url, "_blank"); //, "top=400,left=500,height=380,width=680");
setTimeout(andthen, 2000);
}
}
}
function pick_a_sentence() {
var p="", s="", mb="", ii, jj=eval(prefix.length - 1), kk=-1, ll=-1, mm, nn;
oklist = ":";
sentencepick = Math.floor((Math.random()*kl)+0);
threepick = Math.floor((Math.random()*3)+0);
for (ii=0; ii<prefix.length; ii++) {
if (derived_sentences[sentencepick].indexOf(prefix[ii]) != -1 && prefix[ii] != "") jj = ii;
}
for (ii=0; ii<suffix.length; ii++) {
if (ll == -1 && derived_sentences[sentencepick].indexOf(suffix[ii]) != -1 && suffix[ii] != "") {
ll = ii;
mb = derived_sentences[sentencepick].replace(prefix[jj], "").replace(suffix[ll], "").trim();
//alert(midbit.length + ":" + threepick + " " + derived_sentences[sentencepick] + " originally, then mb=*" + mb + "* derived_sentences[" + sentencepick + "].replace('" + prefix[jj] + "' + ' ','').replace('" + suffix[ll] + "' + ' ','').replace(' ', '').replace(' ', '')=" + derived_sentences[sentencepick].replace(prefix[jj] + " ", "").replace(suffix[ll], ""));
}
}
for (ii=0; ii<midbit.length; ii++) {
if (midbit[ii].indexOf(mb) > -1) kk = ii;
}
//alert(derived_sentences[sentencepick]);
real_sentence = derived_sentences[sentencepick];
unknownselect = "<select id='unknown'></select>";
if (threepick == 0) {
pseudo_sentence = ("... " + midbit[kk] + " " + suffix[ll]).replace(" ", " ").replace(" ", " ").replace("undefined", "");
s = "<td>" + (" " + midbit[kk] + " " + suffix[ll]).replace(" ", " ") + "</td>";
//unknownselect = "<td>" + cprefix.replace("sfirst", "unknown").replace("none;", "block;").replace("</select>", "<option value='' selected>Please select a sentence prefix above (instead of ... below)</option></select></td>");
unknownselect = "<td>" + cprefix.replace("<select", "<select onchange='check_answer(this);'").replace("sfirst", "unknown").replace("none;", "block;").replace("</select>", "<option value='' selected>... </option></select></td>");
//alert("kk=" + kk + " and ll=" + ll + " and pseudo_sentence=" + pseudo_sentence + " and s=" + s + " and unknownselect=" + unknownselect);
if (jj == eval(prefix.length - 1)) {
//alert("jj=" + jj);
//alert("prefix=" + prefix);
oklist = oklist + ppl + ":";
} else {
for (mm=0; mm<derived_sentences.length; mm++) {
for (nn=0; nn<prefix.length; nn++) {
if (pseudo_sentence.replace("...", prefix[nn]).replace(" ", " ").replace(" ", " ").trim() == derived_sentences[mm].trim() && oklist.indexOf(":" + nn + ":") == -1) {
oklist = oklist + nn + ":";
}
}
}
}
} else if (threepick == 1) {
pseudo_sentence = (prefix[jj] + " ... " + suffix[ll]).replace(" ", " ").replace(" ", " ").replace("undefined", "");
p = "<td>" + prefix[jj] + " " + "</td>";
s = "<td>" + " " + suffix[ll] + "</td>";
//unknownselect = "<td>" + cmidbit.replace("smiddle", "unknown").replace("none;", "block;").replace("</select>", "<option value='' selected>Please select a sentence middle word (or not) above (instead of ... below)</option></select></td>");
unknownselect = "<td>" + cmidbit.replace("<select", "<select onchange='check_answer(this);'").replace("smiddle", "unknown").replace("none;", "block;").replace("</select>", "<option value='' selected> ... </option></select></td>");
//alert("kk=" + kk + " and ll=" + ll + " and pseudo_sentence=" + pseudo_sentence + " and s=" + s + " and unknownselect=" + unknownselect);
for (mm=0; mm<derived_sentences.length; mm++) {
for (nn=0; nn<midbit.length; nn++) {
if (pseudo_sentence.replace("...", midbit[nn]).replace(" ", " ").replace(" ", " ").trim() == derived_sentences[mm].trim() && oklist.indexOf(":" + nn + ":") == -1) {
oklist = oklist + nn + ":";
}
}
}
} else {
pseudo_sentence = (prefix[jj] + " " + midbit[kk] + " ...").replace(" ", " ").replace(" ", " ").replace("undefined", "");
p = "<td>" + (prefix[jj] + " " + midbit[kk] + " ").replace(" ", " ") + "</td>";
//unknownselect = "<td>" + csuffix.replace("slast", "unknown").replace("none;", "block;").replace("</select>", "<option value='' selected>Please select a sentence ending above (instead of ... below)</option></select></td>");
unknownselect = "<td>" + csuffix.replace("<select", "<select onchange='check_answer(this);'").replace("slast", "unknown").replace("none;", "block;").replace("</select>", "<option value='' selected> ...</option></select></td>");
//alert("kk=" + kk + " and ll=" + ll + " and pseudo_sentence=" + pseudo_sentence + " and s=" + s + " and unknownselect=" + unknownselect);
for (mm=0; mm<derived_sentences.length; mm++) {
for (nn=0; nn<suffix.length; nn++) {
if (pseudo_sentence.replace("...", suffix[nn]).replace(" ", " ").replace(" ", " ").trim() == derived_sentences[mm].trim() && oklist.indexOf(":" + nn + ":") == -1) {
oklist = oklist + nn + ":";
}
}
}
}
document.getElementById('dunknown').innerHTML = "<table><tr>" + p.replace("undefined", "") + unknownselect.replace("<td> undefined", "<td> ").replace("<td>undefined ", "<td> ") + s.replace("undefined", "") + "</tr></table>";
placetext();
}
function addsome() {
"Making pontoon with first card of Picture card (K,Q,J) or 10", "involves 4 chances for 51 choices", "has a probability of 4/51."
var two="", three="", one=prompt("Enter first of your probability sentences", "Making pontoon with first card being an Ace");
if (one != "") {
two=prompt("Enter second of your probability sentences that started with " + one.replace("⁻", "⁻").replace("₀", "₀").replace("₀", "₀").replace("₁", "₁").replace("₁", "₁").replace("₂", "₂").replace("₂", "₂").replace("₃", "₃").replace("₃", "₃").replace("₄", "₄").replace("₄", "₄").replace("₅", "₅").replace("₅", "₅").replace("₆", "₆").replace("₆", "₆").replace("₇", "₇").replace("₇", "₇").replace("₈", "₈").replace("₈", "₈").replace("₉", "₉").replace("₉", "₉"), "involves 4x4 chances for 51 choices");
if (two != "") {
three=prompt("Enter third of your probability sentences that started with " + one.replace("⁻", "⁻").replace("₀", "₀").replace("₀", "₀").replace("₁", "₁").replace("₁", "₁").replace("₂", "₂").replace("₂", "₂").replace("₃", "₃").replace("₃", "₃").replace("₄", "₄").replace("₄", "₄").replace("₅", "₅").replace("₅", "₅").replace("₆", "₆").replace("₆", "₆").replace("₇", "₇").replace("₇", "₇").replace("₈", "₈").replace("₈", "₈").replace("₉", "₉").replace("₉", "₉") + " " + two.replace("⁻", "⁻").replace("₀", "₀").replace("₀", "₀").replace("₁", "₁").replace("₁", "₁").replace("₂", "₂").replace("₂", "₂").replace("₃", "₃").replace("₃", "₃").replace("₄", "₄").replace("₄", "₄").replace("₅", "₅").replace("₅", "₅").replace("₆", "₆").replace("₆", "₆").replace("₇", "₇").replace("₇", "₇").replace("₈", "₈").replace("₈", "₈").replace("₉", "₉").replace("₉", "₉"), "has a probability of " + eval(16.0 / 51.0));
if (three != "") {
sentenceparts[sentenceparts.length] = one.replace("⁻", "⁻").replace("₀", "₀").replace("₀", "₀").replace("₁", "₁").replace("₁", "₁").replace("₂", "₂").replace("₂", "₂").replace("₃", "₃").replace("₃", "₃").replace("₄", "₄").replace("₄", "₄").replace("₅", "₅").replace("₅", "₅").replace("₆", "₆").replace("₆", "₆").replace("₇", "₇").replace("₇", "₇").replace("₈", "₈").replace("₈", "₈").replace("₉", "₉").replace("₉", "₉");
sentenceparts[sentenceparts.length] = two.replace("⁻", "⁻").replace("₀", "₀").replace("₀", "₀").replace("₁", "₁").replace("₁", "₁").replace("₂", "₂").replace("₂", "₂").replace("₃", "₃").replace("₃", "₃").replace("₄", "₄").replace("₄", "₄").replace("₅", "₅").replace("₅", "₅").replace("₆", "₆").replace("₆", "₆").replace("₇", "₇").replace("₇", "₇").replace("₈", "₈").replace("₈", "₈").replace("₉", "₉").replace("₉", "₉");
sentenceparts[sentenceparts.length] = three.replace("⁻", "⁻").replace("₀", "₀").replace("₀", "₀").replace("₁", "₁").replace("₁", "₁").replace("₂", "₂").replace("₂", "₂").replace("₃", "₃").replace("₃", "₃").replace("₄", "₄").replace("₄", "₄").replace("₅", "₅").replace("₅", "₅").replace("₆", "₆").replace("₆", "₆").replace("₇", "₇").replace("₇", "₇").replace("₈", "₈").replace("₈", "₈").replace("₉", "₉").replace("₉", "₉");
onloading();
}
}
}
}
</script>
</head>
<body align="center" onload="onloading();">
<h1 align="center">Probability Dot<a title="Add your own threesome" onclick="addsome();" href="#">Dot</a>Dot Game</h1>
<h2 align="center" id="score">Score is 0 from 0 goes<a target=_blank href='http://robinhawke.wordpress.com/category/three-sentence-stories/' title='Probability ideas ... thanks'>.</a></h2>
<div align="center" id='dsentence'></div><div align="center" id='dunknown'></div>
<canvas style='border: 5px solid green; background-color: black; opacity: 0.3;' title='Click for your next threesome to solve' id="canvaselement" width="1350" height="700" style="border: 1px solid green;" />
<script language="JavaScript">
var toggle = 0;
var goodx = 200;
var goody = 200;
var inidone = 0;
var curcard = 0;
var suffix = "";
var scoretoget = 20;
var elem = document.getElementById('canvaselement');
var elemLeft = elem.offsetLeft;
var elemTop = elem.offsetTop;
var context = elem.getContext('2d');
var arr=['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'];
// Add event listener for `click` events.
elem.addEventListener('click', function(event) {
elem.width = elem.width;
elem.style.backgroundImage = "none";
elem.style.opacity = 1.0;
var x = event.pageX - elemLeft;
var y = event.pageY - elemTop;
x = goodx;
y = goody;
var r = Math.floor((Math.random()*256)+0);
var g = Math.floor((Math.random()*256)+0);
var b = Math.floor((Math.random()*256)+0);
var thiscol ='#' + arr[(r-(r % 16)) / 16] + arr[r % 16] + arr[(g-(g % 16)) / 16] + arr[g % 16] + arr[(b-(b % 16)) / 16] + arr[b % 16];
elem.style.backgroundColor = thiscol;
pick_a_sentence();
}, false);
function rbitof(num) {
var ipos;
var str = "";
if (num >= 0) {
ipos = real_sentence.indexOf(". ");
if (ipos == -1 || num == 2) {
str = real_sentence;
real_sentence = "";
return str;
} else {
str = real_sentence.substring(0, (ipos + 1));
real_sentence = real_sentence.substring((ipos + 1)).trim();
return str;
}
}
return "";
}
function pbitof(num) {
var ipos;
var str = "";
if (num >= 0) {
ipos = pseudo_sentence.indexOf(". ");
if (ipos == -1 || num == 2) {
str = pseudo_sentence;
pseudo_sentence = "";
return str;
} else {
str = pseudo_sentence.substring(0, (ipos + 1));
pseudo_sentence = pseudo_sentence.substring((ipos + 1)).trim();
return str;
}
}
return "";
}
function placetext() {
context.font = cf;
var wasp = pseudo_sentence;
context.strokeText(pseudo_sentence,gpx,gpy);
pseudo_sentence = wasp;
//gpy = gpy + 50;
}
function placerealtext() {
context.font = cf;
var wasp = real_sentence;
var huhp = real_sentence.indexOf("involves");
if (huhp != -1) {
context.strokeText(real_sentence.substring(0,huhp).replace("⁻", "⁻").replace("₀", "₀").replace("₀", "₀").replace("₁", "₁").replace("₁", "₁").replace("₂", "₂").replace("₂", "₂").replace("₃", "₃").replace("₃", "₃").replace("₄", "₄").replace("₄", "₄").replace("₅", "₅").replace("₅", "₅").replace("₆", "₆").replace("₆", "₆").replace("₇", "₇").replace("₇", "₇").replace("₈", "₈").replace("₈", "₈").replace("₉", "₉").replace("₉", "₉"),gpx,(gpy + 170));
context.strokeText(real_sentence.substring(huhp).replace("⁻", "⁻").replace("₀", "₀").replace("₀", "₀").replace("₁", "₁").replace("₁", "₁").replace("₂", "₂").replace("₂", "₂").replace("₃", "₃").replace("₃", "₃").replace("₄", "₄").replace("₄", "₄").replace("₅", "₅").replace("₅", "₅").replace("₆", "₆").replace("₆", "₆").replace("₇", "₇").replace("₇", "₇").replace("₈", "₈").replace("₈", "₈").replace("₉", "₉").replace("₉", "₉"),gpx,(gpy + 220));
} else {
context.strokeText(real_sentence.replace("⁻", "⁻").replace("₀", "₀").replace("₀", "₀").replace("₁", "₁").replace("₁", "₁").replace("₂", "₂").replace("₂", "₂").replace("₃", "₃").replace("₃", "₃").replace("₄", "₄").replace("₄", "₄").replace("₅", "₅").replace("₅", "₅").replace("₆", "₆").replace("₆", "₆").replace("₇", "₇").replace("₇", "₇").replace("₈", "₈").replace("₈", "₈").replace("₉", "₉").replace("₉", "₉"),gpx,(gpy + 170));
}
real_sentence = wasp;
//gpy = gpy + 50;
}
updatescore();
</script>
</body>
</html>