' VBScript File
'Sub to set page back to original format
Sub setpage()
btncolset
divResult.innerText = ""
document.body.bgcolor = "#99ccff"
End Sub
'Sub to disable or enable the buttons, depending on the state needed
Sub btndisable(state)
For i=0 To 7
document.getElementById("btn" & letters(i)).disabled = state
Next
End Sub
'Sub to set the buttons to their original colour
Sub btncolset()
For i=0 To 7
document.getElementById("btn" & letters(i)).style.backgroundColor = "White"
Next
End Sub
'Sub to run correct procedures when button is clicked
Sub btnsounds(file,obj)
If rdlearn.checked = True Then
genderset
phonicsnd.URL = file
lrnpress = True
Else
phonicsnd.URL = file
Check obj
End If
End Sub
'Sub that is run to check whether the user's answer is correct or wrong in Game mode
Sub Check(Obj)
btndisable True
If Obj.id = "btn" & letters(p) Then
correct = True
colorchange "Yellow", Obj, "Lime"
If learned = True Then
starnum = starnum + 1
Else
starnum = starnum + 2
End If
Stars
Checkwin
Else
correct = False
colorchange "Red", Obj, "Red"
document.getElementById("btn" & letters(p)).style.backgroundColor = "Lime"
End If
p=(Int(Rnd()*8))
Randomit
learned = False
lrnpress = False
qclick = False
genderset
End Sub
'Sub to change element colours when check is run
Sub colorchange(body, Obj, button)
shadetxt
document.body.bgcolor = body
Obj.style.backgroundColor = button
End sub
'Sub to make background colour of text correspond with type of answer
Sub shadetxt()
Const stTag = ""
h = h & Mid(divtext,character,1)
h = h & ""
Next
divResult.innerHTML = h
End Sub
'Sub to change stars colour when user is correct
Sub Stars()
If starnum <= 10 Then
For i=1 To starnum
document.getElementById("imgstar"&i).src = "sourcefiles/StarOn.gif"
Next
Else
For i=1 To 10
document.getElementById("imgstar"&i).src = "sourcefiles/StarOn.gif"
Next
End If
End Sub
'Sub to check whether the user has won the game and inform them if they have
Sub Checkwin()
If starnum >=10 Then
MsgBox "Well done. You've Won!!!", vbOKOnly + vbExclamation, "Congratulations!"
Reset
End If
End Sub
'Sub to reset the program back to its original state
Sub Reset()
For i=1 To 10
document.getElementById("imgstar" & i).src = "sourcefiles/StarOff.gif"
Next
p=(Int(Rnd()*8))
rdlearn.checked = True
chosenreset
setpage
starnum = 0
btndisable False
btnQuestion.style.visibility = "hidden"
End Sub
'Sub to check whether the random number generator has selected a phonic that has already been played,
'and to re-evaluate if this is the case.
Sub Randomit()
Dim l 'starting variable of for-next loop
Dim used 'defines if the letter chosen has already been used
Dim continue 'defines whether the phonic needs to be re-evaulated or not
used = False
continue = False
If valarray <8 Then
Do Until continue = True
For l=1 To valarray
If chosen(l) = letters(p) Then
used = True
End If
Next
If used = True Then
p=(Int(Rnd()*8))
used = False
Else
continue = True
End If
Loop
valarray = valarray + 1
chosen(valarray) = letters(p)
Else
chosenreset
End If
End Sub
'Sub to reset the selected phonics array
Sub chosenreset()
chosen(1) = letters(p)
chosen(2) = ""
chosen(3) = ""
chosen(4) = ""
chosen(5) = ""
chosen(6) = ""
chosen(7) = ""
chosen(8) = ""
valarray = 1
End Sub
'Sub to place the stars into the html
Sub starmake()
Dim html
html = ""
For i=1 To 10
html = html & "
"
Next
tdstars.innerHTML = tdstars.innerHTML & html
End Sub
'Sub to randomly decide which gender of sound to play
Sub genderset()
Dim g
g = Int(Rnd()*2)
If g=1 Then
gender = "Boy-"
Else
gender = "Girl-"
End If
End Sub